Quick intro to MongoDB
(really.... it's quick and it's just an intro...)
A NoSQL (often interpreted as Not Only SQL) database provides a mechanism for storage and retrieval of data that is modeled in means other than the tabular relations used in relational databases.
en.wikipedia.org/wiki/NoSQL
NoSQL
Which basically means
- A database is a database.
- Groups of records (tables) are actually called collections.
- Each collection comprises documents, same as tables contain records.
Show me the money...
// get all collections in a database
db.getCollectionNames();
$ unicorns
console says...
draw your own conclusions...
db.COLLECTION_NAME.COMMAND()
how many _____?
//db.COLLECTION_NAME.COMMAND()
db.unicorns.count();
$ 12 documents in unicorns
what do we have here?
db.unicorns.find().pretty();
{
"_id" : ObjectId("545b120902e441c9bade77b4"),
"name" : "Horny",
"dob" : "1992-03-14T07:47:00Z",
"gender" : "m",
"loves" : [
"carrot",
"papaya"
],
"weight" : 600,
"vampires" : 63
}
{
"_id" : ObjectId("545b120902e441c9bade77b5"),
"name" : "Aurora",
"dob" : "1991-01-25T13:14:00Z",
"gender" : "f",
"loves" : [
"carrot",
"grape"
],
"weight" : 450,
"vampires" : 43
}
{
"_id" : ObjectId("545b120902e441c9bade77b6"),
"name" : "Unicrom",
"dob" : "1973-02-10T22:10:00Z",
"gender" : "m",
"loves" : [
"energon",
"redbull"
],
"weight" : 984,
"vampires" : 182
}
{
"_id" : ObjectId("545b120902e441c9bade77b7"),
"name" : "Roooooodles",
"dob" : "1979-08-18T18:44:00Z",
"gender" : "m",
"loves" : [
"apple"
],
"weight" : 575,
"vampires" : 99
}
{
"_id" : ObjectId("545b120902e441c9bade77b8"),
"name" : "Solnara",
"dob" : "1985-07-05T02:01:00Z",
"gender" : "f",
"loves" : [
"apple",
"carrot",
"chocolate"
],
"weight" : 550,
"vampires" : 80
}
{
"_id" : ObjectId("545b120902e441c9bade77b9"),
"name" : "Ayna",
"dob" : "1998-03-08T08:30:00Z",
"gender" : "f",
"loves" : [
"strawberry",
"lemon"
],
"weight" : 733,
"vampires" : 40
}
{
"_id" : ObjectId("545b120902e441c9bade77ba"),
"name" : "Kenny",
"dob" : "1997-07-02T10:42:00Z",
"gender" : "m",
"loves" : [
"grape",
"lemon"
],
"weight" : 690,
"vampires" : 39
}
{
"_id" : ObjectId("545b120902e441c9bade77bb"),
"name" : "Raleigh",
"dob" : "2005-05-04T00:57:00Z",
"gender" : "m",
"loves" : [
"apple",
"sugar"
],
"weight" : 421,
"vampires" : 2
}
{
"_id" : ObjectId("545b120902e441c9bade77bc"),
"name" : "Leia",
"dob" : "2001-10-09T14:53:00Z",
"gender" : "f",
"loves" : [
"apple",
"watermelon"
],
"weight" : 601,
"vampires" : 33
}
{
"_id" : ObjectId("545b120902e441c9bade77bd"),
"name" : "Pilot",
"dob" : "1997-03-27T05:03:00Z",
"gender" : "m",
"loves" : [
"apple",
"watermelon"
],
"weight" : 650,
"vampires" : 54
}
{
"_id" : ObjectId("545b120902e441c9bade77be"),
"name" : "Nimue",
"dob" : "1999-12-20T16:15:00Z",
"gender" : "f",
"loves" : [
"grape",
"carrot"
],
"weight" : 540,
"vampires" : 49
}
{
"_id" : ObjectId("545b120902e441c9bade77bf"),
"name" : "Dunx",
"dob" : "1976-07-19T19:18:00Z",
"gender" : "m",
"loves" : [
"grape",
"watermelon"
],
"weight" : 704,
"vampires" : 165
}
Quick intro to MongoDB
By Axel Uriel Martínez Castillo
Quick intro to MongoDB
- 414