Hi Ryan Ang Wei En

class Fruit(ndb.Model):
>   name = ndb.StringProperty(required=True)
>   color = ndb.StringProperty(required=True)
>   taste = ndb.StringProperty(required=True)
>

Dont use a 'name' field for ID. There is a 'id' keyword for this purpose.

...

class Fruit(ndb.Model):
    color = ndb.StringProperty()
    taste = ndb.StringProperty()

...

apple1 = Fruit(id="apple", color='1', taste='1')
apple1.put()
apple2 = Fruit(id="apple", color='2', taste='2')
apple2.put()

# restore apple1 from ndb after saving apple2
apple1 = apple1.key.get()
self.assertEqual(apple1.color, apple2.color)

# one item into ndb
apple_count = len(Fruit.query().fetch(100))
self.assertEqual(apple_count, 1)


-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/google-appengine.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-appengine/558c389c-ca04-4633-884b-fe3403160307%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to