0

I'm thinking to create a property which store the key or the ID of the other entity as a reference to the entity.
I want to know two things.
1. Which data should the property store, the key or the ID?
2. What should the type of the property be? maybe StringProperty?

Nigiri
  • 3,469
  • 6
  • 29
  • 52

1 Answers1

1

The Datastore has a special property type for this: ReferenceProperty. There are two ways to use it.

One:

someothermodel = db.ReferenceProperty()

Two:

someotherspecificmodel = db.ReferenceProperty(SomeModel)

In example 2, only models with the type of SomeModel can be assigned, in example one, any model can be assigned.

The value type of ReferenceProperty is db.Key.

Linuxios
  • 34,849
  • 13
  • 91
  • 116