gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-04 09:18:20 25 4
gpt4 key购买 nike

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

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

this question 的答案会暗示他们总是保持不变,但我想确定: Use a ListProperty or custom tuple property in App Engine?

最佳答案

文档中的声明是:

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.

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

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

关于python - App Engine 中的列表属性字段是如何排序的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5745178/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com