Reputation: 4483
I have the following code in my app:
query_string = Booking.query()
Which I would like to substitute Booking
(an ndb.Model
class) based on some conditional logic.
I am uncertain how to create a new Booking
or other ndb.Model
's query object "on the fly".
My pseudo code:
my_query_object = ndb.Model('Booking').query()
Is this the correct approach or can I start with a generic ndb.Model
query and specify the type via text further along in the query building process?
Upvotes: 0
Views: 102
Reputation: 4483
OK, as what happens, posting a question often prompts the RTFM angel to my savior.
From the docs here:
Typically, an application creates a Query by calling Model.query(). But it's also possible to call ndb.Query().
Arguments
kind Optional kind string. Normally, the name of a entity class.
So the solution code for my example becomes:
query_string = ndb.Query(kind='Booking')
Upvotes: 2