You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ObjectId constructor does not accept a string #2904
I ran into problems when trying to create a new ObjectId Object with a given String.
There is no constructor function given in your exported ObjectId class.
Could you add this constructor in:
export class ObjectId {}
Can't find in docs/sources/tests/samples any use case where the constructor is used with parameters.
Can you provide any from official source (docs or their repo)?
Can't find in docs/sources/tests/samples any use case where the constructor
is used with parameters.
Can you provide any from official source (docs or their repo)?
—
Reply to this email directly or view it on GitHub #2904 (comment)
.
Well, fromString will not exists anymore (see Automattic/mongoose#1890), so instead of using mongoose.mongo.BSONPure.ObjectID.fromString correct way probably will be to just do following:
var objectId = new mongoose.Types.ObjectId("4eb6e7e7e9b7f4194e000001");
So, in the mongoose.d.ts should be constructor with string parameter, e.g:
Activity
Igorbek commentedon Oct 1, 2014
What library do you mean?
swapzone commentedon Oct 1, 2014
The mongoose library.
On Wed, Oct 1, 2014 at 5:52 PM, Igor Oleinikov [email protected]
wrote:
Igorbek commentedon Oct 1, 2014
Can't find in docs/sources/tests/samples any use case where the constructor is used with parameters.
Can you provide any from official source (docs or their repo)?
swapzone commentedon Oct 1, 2014
I can only describe my personal use case and refer to StackOverflow:
http://stackoverflow.com/questions/6578178/node-js-mongoose-js-string-to-objectid-function
On 01.10.2014, at 21:45, Igor Oleinikov [email protected] wrote:
Can't find in docs/sources/tests/samples any use case where the constructor
is used with parameters.
Can you provide any from official source (docs or their repo)?
—
Reply to this email directly or view it on GitHub
#2904 (comment)
.
Igorbek commentedon Oct 1, 2014
It uses driver-specific constructor. There is another answer, which more situable:
In case of native driver
ObjectIDis mapped toBSONPure.ObjectIDbut it's a generic way.evereq commentedon Mar 4, 2015
Well, fromString will not exists anymore (see Automattic/mongoose#1890), so instead of using mongoose.mongo.BSONPure.ObjectID.fromString correct way probably will be to just do following:
var objectId = new mongoose.Types.ObjectId("4eb6e7e7e9b7f4194e000001");
So, in the mongoose.d.ts should be constructor with string parameter, e.g:
Please let me know if you want me to do Pull request for this or you can do this change yourself.
Thanks!
Agamnentzar commentedon May 18, 2015
Fixed it here: #4373
Updates to Mongoose 4.5.x (DefinitelyTyped#10084)