Python-夏娃。在 Cerberus 模式上声明一个对象 ID 数组

Python-Eve. Declare an array of Object IDs on Cerberus schema

我正在用 Python-Eve 开发一个 API,我需要使用 Cerberus 创建一个 MongoDB 模式声明来表达如下所示的文档:

{
    name : 'John Smith',
    type: 'home',
    devices : [
        ObjectID('1234'),
        ObjectID('ABCD'),
        ObjectID('D2AF'),
    ],
}

我想知道如何声明一个 Cerberus 模式以具有 ObjectID 的数组,就像上面的 devices 键一样。

我想要一个用于其他文档引用数组的模式,并可能使它们可嵌入,就像下面的单元素模式示例一样,取自 Python-Eve documentation :

{
     'author': {
         'type': 'objectid',
         'data_relation': {
             'resource': 'users',
             'field': '_id',
             'embeddable': True
         },
     },        
 }

我怀疑这需要一个自定义类型,但我仍然没有想出如何去做。

好的,找到了如何表达设备:

{   
    'devices': {
        'type': 'list',
        'schema': {
            'type': 'objectid',
            'data_relation': {
                'resource': 'devices',
                'field': '_id',
                'embeddable': True
            },
        }
    }
}

优秀的地狱犬documentation