From charlesreid1

 
Line 17: Line 17:
<pre>
<pre>
> db.collection.drop()
> db.collection.drop()
</pre>
==Insert document into collection==
Use the insert() or insertOne() method: https://docs.mongodb.com/manual/reference/method/db.collection.insertOne/#db.collection.insertOne
<pre>
> db.collection.insert( { 'peanut butter':'jelly' } )
</pre>
</pre>



Latest revision as of 02:47, 1 February 2018

Collections methods: https://docs.mongodb.com/manual/reference/method/js-collection/

Mongo Collections

Collections are the NoSQL equivalent to tables.

Add collection

Like databases, you can create collections by treating them as if they exist; if they do not, they will be created.

Drop collection

Drop collection from mongo shell

From the shell, call the drop() method on the collection you want to drop:

> db.collection.drop()

Insert document into collection

Use the insert() or insertOne() method: https://docs.mongodb.com/manual/reference/method/db.collection.insertOne/#db.collection.insertOne

> db.collection.insert( { 'peanut butter':'jelly' } )

Flags