这似乎应该是一个简单的问题。但是文档似乎没有回答它。使用他们的示例,我想这样做:
Account.query(Account.title == "best")
除了我也想匹配部分字符串。所以在这种情况下:
acct = Account(title="the best account in the world")
带有参数“最佳”的 ndb 查询将匹配acct.
我目前看到的唯一选择是循环遍历Account.query()并将每个模块title与re.searchpython 中的模块匹配。这似乎不是一个好的解决方案。
更新:我也在看gql. 这样做:
acct = ndb.gql('SELECT * from Account WHERE title LIKE '%best%')
返回一个Parse Error: Invalid WHERE Condition at symbol LIKE