App Engine 中的列表属性字段如何排序?

发布于 2024-11-02 10:23:53 字数 513 浏览 2 评论 0原文

我计划将一些数据存储在列表属性中,并希望确保当我查询实体时列表中项目的顺序保持不变。从数据存储区放入和获取数据时是否有这样的保证?

需要明确的是,我并不是试图通过列表属性中的任何内容对一组结果进行排序,我只是想确保我是否有一个字符串列表(例如:“Sam”、“Alberto”、“Rick”) ,当我访问该实体时,它们始终按该顺序排列。

此问题的答案 意味着它们总是保持不变,但我想确定: 使用 ListProperty 或自定义元组属性应用程序引擎?

I am planning to store some data in a listproperty and want to be sure that the order of the items in the list remains the same when I query my entity back out. Is there such a guarantee when putting and getting data from the datastore?

To be clear, I am not trying to order a set of results by anything in the listproperty, I just want to make sure that if I have a list of strings (for example: "Sam", "Alberto", "Rick"), they are always in that order when I access that entity.

The answer to this question would imply that they do always stay the same, but I'd like to be sure:
Use a ListProperty or custom tuple property in App Engine?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

幻梦 2024-11-09 10:23:54

ListProperties 的工作方式与 Python 列表类似;它们已被订购并且将保持订购状态。

ListProperties work just like python lists; they are ordered and will remain ordered.

贩梦商人 2024-11-09 10:23:53

文档中的声明是:

顺序通常会保留,因此当查询和 get() 返回实体时,列表属性值的顺序与存储时的顺序相同。有一个例外:Blob 和 Text 值移至列表末尾;但是,它们相对于彼此保留了原始顺序。

(来自 http://code.google.com/appengine/docs/python /datastore/datamodeling.html

因此,如果您仅存储字符串,则应以正确的顺序返回它们。

The statement from the documentation is:

Order is generally preserved, so when entities are returned by queries and get(), the list properties values are in the same order as when they were stored. There's one exception to this: Blob and Text values are moved to the end of the list; however, they retain their original order relative to each other.

(From http://code.google.com/appengine/docs/python/datastore/datamodeling.html)

So, if you are only storing strings, they should be returned in the correct order.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文