문제

How to insert document in collection name contain dot notation?

For Ex: collection: blog and blog. post Insert: db.blog.insert("document"); how to insert in 2nd collection?

도움이 되었습니까?

해결책

Have you tried

db.blog.post.insert({ /* document */ }); 

?

Keep in mind that such a notation doesn't have any different semantics for mongodb, the collection name blog.post doesn't mean the collection is in any way related to the blog collection, i.e. it doesn't make a difference whether you name your collection blog.post or blog_post or simply posts.

This notation is, however, used by MongoDB for its GridFS implementation which by default writes to db.fs.files and db.fs.chunks.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top