Introduction to the use of MongoDB database C# driver
1: Brief introduction MongoDB is a distributed document database that supports a master-slave structure similar to a relational database. Documents are stored in binary Json form, with no locks, no transactions, and indexes. 2: Installation steps Step 1: Download the assembly http://www.mongodb.org/downloads Part 2: Unzip and extract the relevant bin directory to C:\Mongo (choose this arbitrarily), and create a db folder in this directory. Part 3: Open the CMD window, enter the C:\Mongo\bin directory, and run mongod.exe –dbpath=”c:\Mongo\db” Step 4: Open the CMD window again (keep the previous window open) and run mongo.exe. In this window you can execute simple commands. Here are a few: > j = { name : “mongo” }; {“name” : “mongo”} > t = { x : 3 }; { “x” : 3 } > db.things.save(j); > db.things.save(t); > db.things.find(); { “_id” : ObjectId(“4c2209f9f3924d31102bd84a”), “name” : “mongo” } { “_id” : ObjectId(“4c2209fef3924d31102bd84b”), “x” : 3 } > > for (var i = 1; i <= 20; i++) db.things.save({x : 4, j : i}); > db.things.find(); > var cursor = db.things.find(); > while (cursor.hasNext()) printjson(cursor.next()); > db.things.find().forEach(printjson); > var cursor = db.things.find(); > printjson(cursor[4]); > var arr =…
Introduction to the use of MongoDB database C# driver
1: Brief Introduction MongoDB is a distributed document database that supports a master-slave structure similar to a relational database. Documents are stored in the form of binary Json, lock-free, transaction-free, and indexed. 2: Installation steps Step 1: Download the assembly http://www.mongodb.org/downloads Part 2: Unzip and extract the relevant bin directory to C:\Mongo (this is optional), and create a db folder under this directory. Part 3: Open the CMD window, enter the C:\Mongo\bin directory, and run mongod.exe –dbpath=”c:\Mongo\db” Step 4: Open the CMD window again (keep the previous window open) and run mongo.exe. In this window you can execute simple commands, a few are briefly listed below > j = { name : “mongo” }; the {“name”: “mongo”} > t = { x : 3 }; the { “x” : 3 } > db.things.save(j); > db.things.save(t); > db.things.find(); { “_id” : ObjectId(“4c2209f9f3924d31102bd84a”), “name” : “mongo” } the { “_id” : ObjectId(“4c2209fef3924d31102bd84b”), “x” : 3 } the > > for (var i = 1; i <= 20; i++) db.things.save({x : 4, j : i}); the > db.things.find(); > var cursor = db.things.find(); the > while (cursor.hasNext()) printjson(cursor.next()); the > db.things.find().forEach(printjson); > var cursor = db.things.find(); the > printjson(cursor[4]); > var arr =…