对应于 modelname

编程入门 行业动态 更新时间:2024-10-23 11:33:00
本文介绍了对应于 modelname_set(反向引用属性)的 Google App Engine ndb的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

中是否有与 modelname_set(反向引用的属性)等效的内容Google App Engine 的 NDB?

Is there an equivalent for modelname_set (a back-referenced property) in Google App Engine's NDB?

在旧数据库中,模型实体将反向引用属性描述为:

In the old DB a Model entity had described the back-reference property as:

反向引用属性的名称默认为modelname_set(模型类的名称为小写字母,并在末尾添加_set"),并且可以使用ReferenceProperty构造函数的collection_name参数进行调整.

The name of the back-reference property defaults to modelname_set (with the name of the model class in lowercase letters, and "_set" added to the end), and can be adjusted using the collection_name argument to the ReferenceProperty constructor.

我注意到 NDB db.Model 实例似乎不存在此属性.

I noticed this property does not seem to exist with NDB db.Model instances.

NDB 是否具有与反向引用属性等效的属性?

Does NDB have an equivalent to the back-reference property?

推荐答案

在 NDB 中没有直接的反向引用属性,因为 NDB 与原始数据存储客户端使用的范例并不完全相同.您可以使用 KeyProperty 作为前向引用,然后对所有设置了该 KeyProperty 的内容作为后向引用使用查询.

There is no direct back-reference properties in NDB because NDB doesn't quite use the same paradigm as the original datastore client. You would use a KeyProperty for your forward reference and then use a query for everything that has that KeyProperty set for your back reference.

class Comment(ndb.Model)
    source = ndb.KeyProperty()

qry = Comment.query().filter(source=ndb.Key('Source', 'Sandy'))

这篇关于对应于 modelname_set(反向引用属性)的 Google App Engine ndb的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-04-17 19:43:32,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/921576.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:应于   modelname

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!