- Windows
create a mongodb folder in C: (or wherever you want)
mongod --directoryperdb --dbpath C:\mongodb\data\db --logpath C:\mongodb\log\mongo.log --logappend --rest --install
net start MongoDB
- start it with net which is to handle services
start mongo shell: mongo
shell commands:
cls
- clearshow dbs
- show db listdb
- show active dbuse mycustomers
- create new db and switch to itdb.createUser(.....);
- check documentation to find out standard input formatdb.createCollection('customers');
- create a collection called customersshow collections
db.customers.insert(....);
db.customers.find();
db.customers.find().pretty();
- tabulated printdb.customers.update({field1: "one"}, {field1: "one", field2: "two"});
- this will update all the objects which have "one" as "field1" value with the object given as the second argumentdb.customers.find().count;
- count elements. You can put conditions tofind()
argumentsdb.customers.find.limit(4);
- show only the first 4 objects founddb.customers.find.limit(4).sort({ field: -1 });
- show 4, sort them in descending order (ascending would be 1)db.customers.find().forEach(function(doc){print("Customer Name: "+doc.fieldname)});
- Print all the "fieldname" fields found with the query with the starting text in every line "Customer Name :"
Notes based on Traversy media crash course
A very short intro: Create a dynamoDB on AWS dashboard
You can find local DynamoDB download options on AWS docs, but the best solution seems to be to run it in a Docker container. AWS provides a java sample application here