因此,我需要从我的Collection 中唯一地引用特定的子文档.例如:
User = {
'name': 'jim',
'documents: [
{'id': 0001, 'title': "My document"},
{'id': 0002, 'title': "My second document!"},
]
}
因此,我需要能够为新文档自动创建ID,最好不要在应用程序级别(因为在实际开发场景中会有竞争条件).
有没有办法使用mongo自动生成的ObjectId(在集合级别的_id字段中使用)或类似的东西?