I'm using Mongoose and TypeScript with the interface+class+schema approach.
What is the canonical way to store the _id field?
I know the db stores it as a bson ObjectID. But I've seen some examples using string and others using mongoose's ObjectId, and then converting between them for various reasons - so I'm unsure which to use.
interface Animal {
_id: ?type?; // ?
name: string;
}
Is it advisable to use
stringmongoose.Types.ObjectIdmongodb.ObjectIDbson.ObjectID
Also, assuming it is correct to use objectid - I want to avoid taking a dependency on mongoose in the interface file. Is it safe/advisable to use the bson package's ObjectID instead - are they equivalent?