mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-05 15:27:05 +00:00
Merge pull request #11892 from simonxca/patch-mongoose
Mongoose fixes ObjectId constructor
This commit is contained in:
@@ -525,6 +525,7 @@ mongoose.Types.Buffer.from([1, 2, 3]);
|
||||
*/
|
||||
var objectId: mongoose.Types.ObjectId = mongoose.Types.ObjectId.createFromHexString('0x1234');
|
||||
objectId = new mongoose.Types.ObjectId(12345);
|
||||
objectId = mongoose.Types.ObjectId(12345);
|
||||
objectId.getTimestamp();
|
||||
/* practical examples */
|
||||
export interface IManagerSchema extends mongoose.MongooseDocument {
|
||||
|
||||
Vendored
+16
-4
@@ -1091,10 +1091,22 @@ declare module "mongoose" {
|
||||
}
|
||||
|
||||
/*
|
||||
* section types/objectid.js
|
||||
* http://mongoosejs.com/docs/api.html#types-objectid-js
|
||||
*/
|
||||
class ObjectId extends mongodb.ObjectID {}
|
||||
* section types/objectid.js
|
||||
* http://mongoosejs.com/docs/api.html#types-objectid-js
|
||||
*/
|
||||
var ObjectId: ObjectIdConstructor;
|
||||
|
||||
// mongodb.ObjectID does not allow mongoose.Types.ObjectId(id). This is
|
||||
// commonly used in mongoose and is found in an example in the docs:
|
||||
// http://mongoosejs.com/docs/api.html#aggregate_Aggregate
|
||||
// constructor exposes static methods of mongodb.ObjectID and ObjectId(id)
|
||||
type ObjectIdConstructor = typeof mongodb.ObjectID & {
|
||||
(s?: string | number): mongodb.ObjectID;
|
||||
}
|
||||
|
||||
// var objectId: mongoose.Types.ObjectId should reference mongodb.ObjectID not
|
||||
// the ObjectIdConstructor, so we add the interface below
|
||||
interface ObjectId extends mongodb.ObjectID {}
|
||||
|
||||
/*
|
||||
* section types/embedded.js
|
||||
|
||||
Reference in New Issue
Block a user