在 Node.js 中,如何向 MongoDB 数据库中储存一个 JavaScript 对象
PHPz
PHPz 2017-04-17 11:12:29
0
3
579

我希望在 MongoDB 中储存一个 Mongo 查询,比如可能类似下面这样:

{
    $set: {
        account_id: ObjectID('525284cc2cebb6d0008b4567')
    }
}

但是我并不能直接储存在 MongoDB 中,因为 $set 在 MongoDB 中是一个不合法的属性名。

而且也不能用 JSON 序列化,因为 ObjectID 这种对象序列化之后没法被正确地还原。

PHPz
PHPz

学习是最好的投资!

reply all(3)
黄舟

Escape loses the string...how to unescape it back when needed

Peter_Zhu

Why don’t you just save the ID and spell out the query yourself next time?

阿神

What about BSON serialization?

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template