query mongodb
db.inventory.find( { status: "D" } )
query mongodb
db.inventory.find( { status: "D" } )
Mongo-queries
db.course
.find({price: {$set: {$gte: 8, $lte: 28} }})
.limit(8)
.sort({name: 1})
.select({name: 1, tags: 1})
// operators:
// Comparison:
// $eq, $gt, $gte, $lt, $lte, $ne: a specified value
// $in, $nin : the values specified in an array
// Logical: $and, $not, $nor, $or
// Element: $exists, $type
.......
query mongodb
db.inventory.find( {} )
Mongo Query
using System;
using MongoDB.Driver;
using MongoDB.Bson;
namespace MongoQuery
{
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 builder = Builders<BsonDocument>.Filter;
var filter = builder.Gt("price", 30000) & builder.Lt("price", 55000);
var docs = cars.Find(filter).ToList();
docs.ForEach(doc => {
Console.WriteLine(doc);
});
}
}
}
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