- The assets folder stores metadata, css, and javascript resources
- The connect directory stores database connection information
- The core folder stores ajax information about the comment, share, like, and post system; database; user and post classes exchange data of client and server
- The user directory stores user resources
Prerequisites: Installed MongoDB on Ubuntu
MongoDB is a NoSQL database, that stores documents in JSON format. A collection is an entity in MongoDB (ie similar to a table in RDBMS databases) that stores JSON documents.
You can use one of the following commands from Mongo Shell to list all available collections in the MongoDB database:
show collections
The insertOne() method allows you to insert a single document into a collection. The insertOne() method has the following syntax:
db.collection.insertOne(
<document>,
{ writeConcern: <document>}
)
The insertOne() method accepts two arguments:
The insertMany() allows you to insert multiple documents into a collection. Here is the syntax of the insertMany() method:
db.collection.insertMany(
[document1, document2, ...],
{
writeConcern: <document>,
ordered: <boolean>
}
)
The findOne() returns a single document from a collection that satisfies the specified condition.
The findOne() method has the following syntax:
db.collection.findOne(query, projection)
The findOne() accepts two optional arguments: query and projection.
- The query is a document that specifies the selection criteria.
- The projection is a document that specifies the fields in the matching document that you want to return.
The find() method finds the documents that satisfy a specified condition and returns a cursor to the matching documents.
The following shows the syntax of the find() method:
db.collection.find(query, projection)
query: The query is a document that specifies the criteria for selecting documents from the collection. If you omit the query or pass an empty document({}), the find() returns a cursor that returns all documents in the collection.
projection: The projection is a document that specifies the fields in the matching documents to return. If you omit the projection argument, the find() method returns all fields in the matching documents.
In this tutorial, you’ll how to use the MongoDB projection that allows you to select fields to return from a query. In MongoDB, projection simply means selecting fields to return from a query.
To determine if a field is included in the returned documents, you use the following syntax: { <field>: value, ...}
If the value is 1 or true, the is included in the matching documents. In case the value is 0 or false, it is suppressed from the returned documents.
If the projection document is empty {}, all the available fields will be included in the returned documents.
To specify a field in an embedded document, you use the following dot notation:
The deleteOne() method allows you to delete a single document from a collection.
The deleteOne() method has the following syntax:
db.collection.deleteOne(filter, option)
The deleteOne() method accepts two arguments:
- filter is an required argument. The filter is a document that specifies the condition for matching the document to remove. If you pass an empty document {} into the method, it’ll delete the first document in the collection.
- option is an optional argument. The option is a document that specifies the deletion options.
The deleteMany() method allows you to remove all documents that match a condition from a collection.
The deleteMany() has the following syntax:
db.collection.deleteMany(filter, option)
In this syntax:
- filter is a document that specifies deletion criteria. If the filter is an empty document {}, the deleteMany() method will delete all documents from the collection.
- option is a document that specifies the deletion option.
The updateOne() method allows you to update a single document that satisfies a condition.
The following shows the syntax of the updateOne() method:
db.collection.updateOne(filter, update, options)
In this syntax:
- The filter is a document that specifies the criteria for the update. If the filter matches multiple documents, then the updateOne() method updates only the first document. If you pass an empty document {} into the method, it will update the first document returned in the collection.
- The update is a document that specifies the change to apply.

