NoSQL
Understanding NoSQL | MongoDB
Similar to relational databases (such as MySQL and MSSQL), MongoDB consists of databases, tables, fields but with different names where
Collections are similar to tables or views in MySQL and MSSQL.
Documents are similar to rows or records in MySQL and MSSQL.
Fields are similar to columns in MySQL and MSSQL.
Brief look at operators between MongoDB and MySQL:
$and equivalent to AND in MySQL
$or equivalent to OR in MySQL
$eq equivalent to = in MySQL
Interacting with a MongoDB server
show databases
: list all the databasesuse <database>
: to connect to a databasedb.createCollection()
: create new collectionsdb.getCollectionNames();
: show all available collections within the databasedb.users.insert({id:"1", username: "admin", email: "[email protected]", password: "idk2021!"})
: insert data into users collectiondb.users.find()
: show available documents within the collectiondb.users.update({id:"2"}, {$set: {username: "tryhackme"}}); || db.<collection>.update
: to update a documentdb.users.remove()
: remove a documentdb.users.drop()
: drop a collection
Last updated
Was this helpful?