开发者

How to manually create a DBRef using pymongo?

I want to create a DBRef manually so that I can add an additional field to it. However, when I try to pass the following:

{'$ref': 'projects', '$id': '1029412409721', 'project_name': 'My Project'}

P开发者_C百科ymongo raises an error:

pymongo.errors.InvalidName: key '$id' must not start with '$'

It would seem that pymongo reserve the $ for the special key, leading me to wonder if it is even possible to do what I'm trying to do?


Probably don't want to be creating them manually like that, since keys in DBRefs need to be ordered. We could add an option to create a DBRef instance w/ custom kwargs though, which would solve your problem. If you file a jira for this we should be able to get it out in an upcoming release.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜