Giter Site home page Giter Site logo

mongous's Introduction

Mongous

Mongous, for humongous, is a simple and blazing fast MongoDB driver that uses a jQuery like syntax.

How it works

var $ = require("mongous").Mongous;

$("database.collection").save({my:"value"});

$("database.collection").find({},function(r){
	console.log(r);
});

Done. App development has never felt as close to the shell as this! Making it a breeze to grab'n'store anything anywhere in your code without the nasty hassle of connections, collections, and cascading callbacks.

Database & Collections

  • db('Database.Collection')
    • Database is the name of your database
    • Collection is the name of your collection
    • Examples
      • db('blog.post')
      • db('blog.post.body')

Commands

  • Update db('blog.post').update(find, update, ...)
    • find is the object you want to find.
    • update is what you want to update find with.
    • ...
      • { upsert: true, multi: false }
      • true, true
  • Save db('blog.post').save(what)
    • what is the object to be updated or created.
  • Insert db('blog.post').insert(what...)
    • what is an object to be created. is an array of objects to be created.
    • Examples
      • db('blog.post').save({hello: 'world'})
      • db('blog.post').save([{hello: 'world'}, {foo: 'bar'}])
      • db('blog.post').save({hello: 'world'}, {foo: 'bar'})
  • Remove db('blog.post').remove(what, ...)
    • what is the object to be removed.
    • ... true for atomic.
  • Find db('blog.users').find(..., function(reply){ })
    • reply is the reply from MongoDB.
    • reply.documents are the documents that you found from MongoDB.
    • ...
      params are filtered by type
      • Objects
        • first object is what you want to find.
        • second object are fields you want
          Ex: { name: 1, age: 1 }
        • third object is any of the following options:
          { lim: x, skip: y }
      • Numbers
        • first number is the limit (return all if not specified)
        • second number is the skip
    • Examples
      • db('blog.users').find(5, function(reply){ })
        reply.documents is the first 5 documents,
      • db('blog.users').find(5, {age: 23}, function(reply){ })
        with age of 23,
      • db('blog.users').find({age: 27}, 5, {name: 1}, function(reply){ })
        and a name.
      • db('blog.users').find(5, {age: 27}, {name: 1}, {lim: 10}, function(reply){ })
        is the same as the previous example, except the limit is 10 instead of 5.
      • db('blog.users').find(5, function(reply){ }, 2)
        reply.documents skips the first 2 documents and is the next 3 documents.
      • db('blog.users').find(function(reply){ }, {age: 25}, {}, {limit: 5, skip: 2})
        is the same as the previous example except only of doucments with the age of 25.
  • Operations db('blog.$cmd').find(command,1)
    • command is the database operation command you want to perform.
    • Example db('blog.$cmd').find({drop:"users"},1)
      drops the users collection, deleting it.
  • Authentication db('blog.$cmd').auth(username,password,callback)
    • username, password
      username and password of the 'blog' database
    • callback
      the callback function when authentication is finished.
    • Example
      • db('blog.$cmd').auth('user','pass',function(reply){})
  • Open db().open(host,port)
    • Only necessary to call if you explicitly want a different host and port, elsewise it lazy opens.

Mongous is a reduction ('less is more') of node-mongodb-driver by Christian Kvalheim.

mongous's People

Contributors

acsaga avatar amark avatar

Watchers

 avatar  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.