Answers for "Mongo Query"

C#
3

query mongodb

db.inventory.find( { status: "D" } )
Posted by: Guest on June-30-2020
0

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
.......
Posted by: Guest on August-09-2021
0

query mongodb

db.inventory.find( {} )
Posted by: Guest on June-30-2020
0

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);
            });
        }
    }
}
Posted by: Guest on October-13-2021

C# Answers by Framework

Browse Popular Code Answers by Language