gpt4 book ai didi

python - 使用整数作为 _id 类型为 item_lookup 返回 HTTP 400

转载 作者:太空宇宙 更新时间:2023-11-03 15:35:42 25 4
gpt4 key购买 nike

我的设置如下,主标识符_id使用整数类型。

当我尝试使用以下 URL 访问某个项目(它存在于数据库中)时:http://xxxxxxx/promotions/1485919019667 ,它返回 HTTP 404。

我想知道 _id 是否不能使用 ObjectID 以外的类型?

promotions = {
'item_title': 'promotion',
'item_url' : 'regex("[\d]+")',
'item_lookup': True,
'schema': {
'_id': {
'type': 'integer',
'minlength': 13,
'maxlength': 13,
'required': True,
'unique': True
},
'category': {
'type': 'string',
'allowed': ["MARKETPLACE", "ELAUGETS", "FASHNESS", "FRINKS", "TRENTER", "OTHERS"]
},
'card_id': {
'type': 'string',
'minlength': 1,
'maxlength': 50
},
'title': {
'type': 'string',
'minlength': 5,
'maxlength': 200,
'required': True
},
'description': {
'type': 'string',
'minlength': 5,
'maxlength': 2500,
'required': True
}
}
}

最佳答案

你看过Handling custom ID fields吗?在文档中?引用该页面的标题:

However, you might have collections where your unique identifier is not and ObjectId, and you still want individual document endpoints to work properly. Don’t worry, it’s doable, it only requires a little tinkering.

本教程涵盖了 UUID 字段,但实际上适用于任何自定义类型。

关于python - 使用整数作为 _id 类型为 item_lookup 返回 HTTP 400,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42540255/

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