Git Product home page Git Product logo

globalhaven-backend's Introduction

db.coll.findOne() // returns a single document db.coll.find() // returns a cursor - show 20 results - "it" to display more db.coll.find().pretty() db.coll.find({name: "Max", age: 32}) // implicit logical "AND". db.coll.find({date: ISODate("2020-09-25T13:57:17.180Z")}) db.coll.find({name: "Max", age: 32}).explain("executionStats") // or "queryPlanner" or "allPlansExecution" db.coll.distinct("name")

// Count db.coll.count({age: 32}) // estimation based on collection metadata db.coll.estimatedDocumentCount() // estimation based on collection metadata db.coll.countDocuments({age: 32}) // alias for an aggregation pipeline - accurate count

// Comparison db.coll.find({"year": {$gt: 1970}}) db.coll.find({"year": {$gte: 1970}}) db.coll.find({"year": {$lt: 1970}}) db.coll.find({"year": {$lte: 1970}}) db.coll.find({"year": {$ne: 1970}}) db.coll.find({"year": {$in: [1958, 1959]}}) db.coll.find({"year": {$nin: [1958, 1959]}})

// Logical db.coll.find({name:{$not: {$eq: "Max"}}}) db.coll.find({$or: [{"year" : 1958}, {"year" : 1959}]}) db.coll.find({$nor: [{price: 1.99}, {sale: true}]}) db.coll.find({ $and: [ {$or: [{qty: {$lt :10}}, {qty :{$gt: 50}}]}, {$or: [{sale: true}, {price: {$lt: 5 }}]} ] })

// Element db.coll.find({name: {$exists: true}}) db.coll.find({"zipCode": {$type: 2 }}) db.coll.find({"zipCode": {$type: "string"}})

// Aggregation Pipeline db.coll.aggregate([ {$match: {status: "A"}}, {$group: {_id: "$cust_id", total: {$sum: "$amount"}}}, {$sort: {total: -1}} ])

// Text search with a "text" index db.coll.find({$text: {$search: "cake"}}, {score: {$meta: "textScore"}}).sort({score: {$meta: "textScore"}})

// Regex db.coll.find({name: /^Max/}) // regex: starts by letter "M" db.coll.find({name: /^Max$/i}) // regex case insensitive

// Array db.coll.find({tags: {$all: ["Realm", "Charts"]}}) db.coll.find({field: {$size: 2}}) // impossible to index - prefer storing the size of the array & update it db.coll.find({results: {$elemMatch: {product: "xyz", score: {$gte: 8}}}})

// Projections db.coll.find({"x": 1}, {"actors": 1}) // actors + _id db.coll.find({"x": 1}, {"actors": 1, "_id": 0}) // actors db.coll.find({"x": 1}, {"actors": 0, "summary": 0}) // all but "actors" and "summary"

// Sort, skip, limit db.coll.find({}).sort({"year": 1, "rating": -1}).skip(10).limit(3)

// Read Concern db.coll.find().readConcern("majority")

globalhaven-backend's People

Contributors

pawan62003 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.