Giter Club home page Giter Club logo

mongous's People

Contributors

acsaga avatar amark avatar champii avatar hellocodem avatar imbolo avatar junnanliu666 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mongous's Issues

Auth?

Is there currently a way to provide an authenticated mongo connection using this driver? I did not immediately notice anything, but wanted to double check.

Standard MongoDB Query?

Hello, this query -> db.users.find({subscriptions:'electronics'}) works in a mongoose shell. 'subscriptions' is an array, and I'm returned all users who have the string 'electronics' in their 'subscriptions' array. However, using mongous, I've tried db('myapp.users').find({subscriptions:'electronics'}) and get back nothing. Does mongous not support the standard set of querying options provided by mongoDB?

NPM?

Hello
I can haz npm version of mongous, please?

Save not updating?

I'm trying to use .save() to update some existing records and it doesn't appear to work, though the function itself returns true. Any thoughts?

There is an existing user in the database that looks like this:

{name: 'GitHub User'
   , phone: '801-555-5555'
   , email: '[email protected]'
   , position: 'sr. gitmaster'
   , twitter: 'github'
   , pic: 'https://github.com/images/gravatars/gravatar-140.png'
   , yearsEmployed: '0'
   , _id: 'github-user-1299185222151'
}

I want to add an @ in front of of his twitter name, so I try this with no luck:

mongous("mydb.users").save({name: 'GitHub User'
    , phone: '801-555-5555'
    , email: '[email protected]'
    , position: 'sr. gitmaster'
    , twitter: '@github'
    , pic: 'https://github.com/images/gravatars/gravatar-140.png'
    , yearsEmployed: '0'
    , _id: 'github-user-1299185222151'
});

This doesn't seem to work, but from command line Mongo can do and it does update:

db.users.save({name: 'GitHub User'
    , phone: '801-555-5555'
    , email: '[email protected]'
    , position: 'sr. gitmaster'
    , twitter: '@github'
    , pic: 'https://github.com/images/gravatars/gravatar-140.png'
    , yearsEmployed: '0'
    , _id: 'github-user-1299185222151'
});

Oh and I just figured out that this works as an alternative:

mongous("mydb.users").update({_id:user._id}, user); 

Ability to reference collections without referencing the db name

I like the simplicity of mongous but I don't like how the database name is repeated.
The beauty (or "power") of something like mongodb-node-driver is that I can create a different connection in the unit tests so that I don't run tests on the same database as my development environment. If the database name is mentioned in the source code I'd have to refer to it as a variable each time. An active "variable" that is patchable when running tests.

So, how can I use mongous without having to say the name of the database in any more but one place?

More than 100 records.

For some reason when I do a find or any type of query that returns more than 100 records, it returns in the reply object:

"startingFrom":101 and only one object.

How do I get the previous results?

find method when there are more than 500 records

find method will trigger the callback function multiple times if there are more than 500 records. I think it's a bug.

in find:

     if (msg.more && o.lim == 0) {
        //lim = o.lim - it < 500 ? 500 : o.lim - it;
        this.more(cmd.collectionName, 500, msg.cursorID, id);
      } else {
        con.c.removeListener(id.toString(), con.c.listeners(id.toString())[0]);
      }
      if (fn) {
        return fn(msg);
      }

I think it should be:

     if (msg.more && o.lim == 0) {
        //lim = o.lim - it < 500 ? 500 : o.lim - it;
        this.more(cmd.collectionName, 500, msg.cursorID, id);
      } else {
        con.c.removeListener(id.toString(), con.c.listeners(id.toString())[0]);
        if (fn) { /* move the callback inside the 'else' */
          return fn(msg);
        }
      }

how do you think about it?

Is remote connection possible?

Hi there,

I'm new to Node and Mongo and mongous looks like exactly what I'd like to operate on my DB, except I can't figure out how to connect to it.

I'm hosting my DB with MongoHQ, how would I go about connecting to is using Mongous?

I've tried the following but it didn't work:

var $ = require("mongous").Mongous;
$().open("myhost.mongohq.com","12345").auth("myUserName","myPassword", function(reply){
    console.log("Connected to MongoHQ!");
});

Is this possible using Mongous?

Thanks!

Sorting?

Hello amark,

Just wondering how to go about sorting since the only options I see are "lim" and "skip". Thanks!

Banx

How can i add field?

i have a record like this: {"UserName":"Will","Sex":1}.
then i want to add a "Age" filed,then this record is like this:{"UserName":"Will","Sex":1,age:"30"}.

i can solve it like this : update({"UserName":"Will"},{"UserName":"Will","Sex":1,age:"30"}).
but this method ,must write all fieds.
In mongodb ,"update({"UserName":"Will"},{"$set" : {age:"30"}})" can add field.
Mongous can add field through similars method?

method save() not work

currently:
mongous.prototype.save = function(a) {
return this.update(a, a, 1);
};
I think shoud be so, I tested.
mongous.prototype.save = function(a) {
return this.update({a._id}, a, true);
};

connect the server with username and password

I can't connect to the mongo server with the username and password
code like this:
$().open(host,port);
$('myDb.$cmd').auth(username,password);
which dosn't work
while i can connect to it successfully with mongodb://username:password@host:port/myDb with the mongo-native lib.

Error handling and configuration

I can't find anything on mongous' error handling mechanism.
I dug through the code, but it's not exactly easy to read.

Could you please update the README or Wiki with how errors are handled,
and how mongous can be configured to e.g. set a custom mongo host, port,
auto-reconnect and that sort of stuff?

As far as I can tell errors are only logged, is that correct?

Mongous does not wait for connected

Sometimes the very first db('db.col').find(function(reply) {}) I do never calls the callback function.

For example:
var db = require('./mongous/mongous.js').Mongous;
db('db.col').find(function(reply) {
console.log('Reply: ' + reply);
});

If you run that by itself sometimes it will or will not return what you were looking for.

update by ObjectID support ?

var $ = require("mongous").Mongous;
 
//var by={"_id" :$.ObjectID("5f732913000000f80c000002")};
var by={"_id" :"5f732913000000f80c000002"};


var record={"title" : "test", "url" : "www.google.com" };


$("db.tbl").update(by,record,function(err, updated){
 console.log("update result");
 console.log(err);
 console.log(updated);
 

})

no output only echo

connecting...
connected!

findAndModify?

findAndModify doesn't appear to be supported. Any plans for this?

Count ?

Suppose this is my find query:

db('blog.users').find(function(reply){ }, {age: 25}, {})

How do I count the number of results ? From what I see db('blog.users').find(function(reply){ }, {age: 25}, {}).count() is not possible because there is not a .count() method...

Thanks in advance.

db(db.collection).remove()

remove command is not working after i upgrade mongous to the current version
But after downgrading mongous module to the older version, it is working now!
I am using node v0.6.2

Sorry i forgot to copy and paste the error message.

Koti

Removing by ID

...doesn't seem to be working. I definitely have the ID correct - I set it to be an integer - but the following code fails to remove it:

db.remove({'_id': id});

Where the variable "id" is simply the ID. Any ideas?

mongous.prototype.id

I'm curious why use

Math.round(Math.exp(Math.random() * Math.log(100000)));

to generate id.
Is there any mathematical background behind the formula? or the 'net' module require an id like that?

after a few attempts, I thought this formula is not very good as an random id generator. It has much bigger chance to get a number between 1-10 than other numbers.

try this code in node:

for(var i=0;i<20;i++) {
    var t = Math.round(Math.exp(Math.random() * Math.log(100000)));
    console.log( t );
}

every time I executed the code, I could find numbers between 1-10.
That means if I send many requests to mongous in a short time, the id has a great chance to conflict and one request may trigger the callback which belongs to another request.

Closing DB connection

How can I terminate the DB connection and all the instances of mongous functions?

dot syntax, once a database is connected

I would like to see the database in connection optional. I like to be able to configure/set it up once, and have future commands use the same database, like so:

var $ = require("mongous").Mongous;
var c = nconf.get('database');
$().open(c.host,c.port);
$(c.database + '.$cmd').auth(c.user,c.pass,function(reply){
    db('.people').find(1, {"fname": "Tom"}, function(reply){
        console.log(reply);
    });
});

.people in this case would equal c.database + ".people"

I can sort of do this with var shorthand, but it seems just a tad clunky:

var $ = require("mongous").Mongous;
var c = nconf.get('database'), d = c.database;
$().open(c.host,c.port);
$(d + '.$cmd').auth(c.user,c.pass,function(reply){
    db(d + '.people').find(1, {"fname": "Tom"}, function(reply){
        console.log(reply);
    });
});

Missing License

You do not indicate which license is mongous distributed under, making it tricky to use.

Could you please assign any license to it? (BSD, MIT, GPL, commercial, ...)

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.