Comments (7)
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.
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.
Okay, that looks like it completely resolved the issue. Thank you for all of your help!
from mongojs.
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.
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.
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.
Using mongojs.ObjectId() there is any chance to get a duplicated id?
from mongojs.
Related Issues (20)
- Use native Object.assign instead of xtend HOT 1
- update `var` to `const` - Readme
- How to use collation HOT 2
- updateMany returns an error HOT 1
- Comparison with the official mongodb package
- Is $text supported within find()? HOT 1
- SCRAM-SHA-256 (and more)
- Publish version with mongodb ^3 HOT 3
- how to set remote connection to mongodb HOT 3
- How do i show dbs, similar to shell "show dbs" HOT 1
- Using replicaSet and readPreference option HOT 1
- "failed to connect to server" even after mongodb is back up HOT 1
- Compatible with hapijs 18? HOT 2
- MongoDB Atlas's URI does not work HOT 5
- collection.update no longer usable for overwriting an entry HOT 16
- v2.6.0 up to v3.1.0 update operation error! HOT 5
- .findOne() query just returns undefined on callback HOT 2
- Does this support aws document db?
- Found Vulnerability 'Regular Expression Denial of Service (ReDoS)' in Synk.io
- How to connect to mongo atlas?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mongojs.