O
O
odd-look2015-01-28 14:05:25
Node.js
odd-look, 2015-01-28 14:05:25

How to add a collection to mongodb?

There is a server on a node with authorization, I communicate with the database through mongoose. I want to make an editable list for each user. If I understand correctly, I need to make an additional collection to the existing database. Actually, how to do it? Will there be a conflict with the login data collection?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Vasiliev, 2015-01-28
@odd-look

In mongo, collections, like the bases themselves, are added on the fly, on-demand.

MongoDB shell version: 2.4.9
connecting to: test
Welcome to the MongoDB shell.
For interactive help, type "help".
For more comprehensive documentation, see
  http://docs.mongodb.org/
Questions? Try the support group
  http://groups.google.com/group/mongodb-user
> db.getCollectionNames()
[ ]
> db.foo.insert({})
> db.getCollectionNames()
[ "foo", "system.indexes" ]
>

That is, you only need to add a new model to mongoose.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question