Giter Club home page Giter Club logo

Comments (7)

cioddi avatar cioddi commented on May 24, 2024
var mongojs = require("mongojs")({});
var ObjectId = mongojs.ObjectId;
console.log(mongojs);
var my_objectID = ObjectId("objectidhere");

should work
or with your example

var objectID = require("mongojs")({}).ObjectId("objectidhere");

from mongojs.

JesseDunlap avatar JesseDunlap commented on May 24, 2024

Awesome, that worked. This is kind of strange, though. I played around with the objects trying to find ObjectId and I noticed that it was present in an initialized instance of mongojs. I attempted to use that, but was given another issue. I believe it was actually in the ObjectId function, and it was unable to resolve the ObjectId function it was calling. I'm unable to access the computer that this particular issue occurred on at the moment, but that looks to have resolved the issue on another computer. Thank you for your help, and I'll get back to you as soon as possible with the details of that other problem, if it's still present!

from mongojs.

JesseDunlap avatar JesseDunlap commented on May 24, 2024

Okay, that looks like it completely resolved the issue. Thank you for all of your help!

from mongojs.

JesseDunlap avatar JesseDunlap commented on May 24, 2024

Woops, looks like I spoke too soon. In the latest version of mongojs, I am getting this error, coming from index.js on line 217:

return new mongodb.BSONNative.ObjectID(id);

TypeError: Cannot read property 'ObjectID' of undefined
    at Object.that.ObjectId (*****/mongojs/index.js:217:32)

This was just working, but I must have been running an outdated, but working version of mongojs. Very frustrating! I am using the code that was suggested above, and this exception happens when I attempt to call the ObjectId function of the database.

from mongojs.

JesseDunlap avatar JesseDunlap commented on May 24, 2024

This is resolved by changing line 217 to:

return new mongodb.ObjectID(id);

I just made this change locally, and I can create a pull request if necessary, but it would probably just be easier for someone with direct access to change it.

from mongojs.

mafintosh avatar mafintosh commented on May 24, 2024

Thank you! This fix was released in 0.6.3.
ObjectId is also exposed directly on the package again:

var mongojs = require('mongojs');
var oid = mongojs.ObjectId(...);

from mongojs.

wallynm avatar wallynm commented on May 24, 2024

Using mongojs.ObjectId() there is any chance to get a duplicated id?

from mongojs.

Related Issues (20)

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.