开发者

How can I combine Schema and noSchema with Mongoose?

I know I have to define Schema's in Mongoose, but I have a case where I'm connecting to a MongoDB via

dsn = "mongodb://#{config.database.username}:#{config.database.password}@#{conf开发者_运维技巧ig.database.host}/{config.database.name}"
mongoose.connect(dsn, (err) -> throw err if err)

And most of my writes will be using Models the way I'm supposed to. But there is this one read that I have to do from a Collection and it's Schema-less. Meaning, it's unprocessed data that was stored by another process. How can I successfully read from that then write to other collections using my Schemas?

If I use mongoose, can I not do this?


To start with you can just make a blank schema for it.

var OtherSchema = new Schema({}, {collection: 'your-collection-name'});

Mongoose.model('Other', OtherSchema);

// ..

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜