mongodb insert
db.products.insert( { item: "card", qty: 15 } )
mongodb insert
db.products.insert( { item: "card", qty: 15 } )
insert command mongo
db.collection.insert( { item: "card", qty: 15 } )
Mongo Insert
using MongoDB.Driver;
using MongoDB.Bson;
namespace InsertDocument
{
class Program
{
static void Main(string[] args)
{
var dbClient = new MongoClient("mongodb://127.0.0.1:27017");
IMongoDatabase db = dbClient.GetDatabase("testdb");
var cars = db.GetCollection<BsonDocument>("cars");
var doc = new BsonDocument
{
{"name", "BMW"},
{"price", 34621}
};
cars.InsertOne(doc);
}
}
}
mongo db const insertDocuments
const insertDocuments = function(db, callback) {
// Get the documents collection
const collection = db.collection('documents');
// Insert some documents
collection.insertMany([
{a : 1}, {a : 2}, {a : 3}
], function(err, result) {
assert.equal(err, null);
assert.equal(3, result.result.n);
assert.equal(3, result.ops.length);
console.log("Inserted 3 documents into the collection");
callback(result);
});
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us