Merge pull request #4373 from Agamnentzar/master

mongoose: fixes for ObjectId
This commit is contained in:
Horiuchi_H
2015-05-18 14:04:37 +09:00
2 changed files with 18 additions and 3 deletions
+10 -1
View File
@@ -364,5 +364,14 @@ schema.virtual('display_name')
.get(function(): string { return this.name; })
.set((value: string): void => {});
var id : mongoose.Types.ObjectId;
var id: mongoose.Types.ObjectId = new mongoose.Types.ObjectId('foo');
var id2: mongoose.Types.ObjectId = new mongoose.Types.ObjectId(123);
var id2: mongoose.Types.ObjectId = mongoose.Types.ObjectId.createFromTime(123);
var id2: mongoose.Types.ObjectId = mongoose.Types.ObjectId.createFromHexString('foo');
var s = id.toHexString();
var valid = id.isValid();
var eq = id.equals(id2);
var kitty1 = new Kitty({});
var kitty2 = new Kitty({});
var kittyEq = kitty1._id.equals(kitty2._id);
+8 -2
View File
@@ -79,7 +79,13 @@ declare module "mongoose" {
}
export module Types {
export class ObjectId {
toHexString(): string;
constructor(id: string|number);
toHexString(): string;
equals(other: ObjectId): boolean;
getTimestamp(): Date;
isValid(): boolean;
static createFromTime(time: number): ObjectId;
static createFromHexString(hexString: string): ObjectId;
}
}
@@ -374,7 +380,7 @@ declare module "mongoose" {
export interface Document {
id?: string;
_id: string;
_id: Types.ObjectId;
equals(doc: Document): boolean;
get(path: string, type?: new(...args: any[]) => any): any;