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 }}
This repository has been archived by the owner on Jun 29, 2021. It is now read-only.
Hi.
I'm using yet typegoose 3.5.2 because 3.6.0 don't works for me (see #68).
I defined a model with the "_id" field to simplify the configuration of data on db. This is not frequently but it works and it is admitted with mongoose.
When I load in memory a doc defined with an array of items wich are defined with an "_id" field, the array is empty.
Below the source file.
import*astgfrom'typegoose';exportclasspermextendstg.Typegoose{
@tg.prop()routerFunction : string;
@tg.prop()permit: boolean;}exportconstpermModel=newperm().getModelForClass(perm);exportclassgroupextendstg.Typegoose{
@tg.prop({required: true,index: true,unique: true})_id: string;
@tg.prop({required: true,index: true,unique: true})name : string;
@tg.arrayProp({itemsRef: perm})perms ?: tg.Ref<perm>[];}exportconstgroupModel=newgroup().getModelForClass(group);exportclassadminextendstg.Typegoose{
@tg.prop()name : string;
@tg.arrayProp({itemsRef: group})groups ?: tg.Ref<group>[];
@tg.arrayProp({itemsRef: perm})perms ?: tg.Ref<perm>[];}exportconstadminModel=newadmin().getModelForClass(admin);adminModel.findById('an id').exec((err,data)=>{console.log(data);// prints correctly the perms array data but an empty groups array}
The text was updated successfully, but these errors were encountered:
Thank you @derchirurg but your answer is not complete.
I tried to remove the _id definition field but:
if I save an _id as string I can't use that to find the recors and I can't load that field with typegoose using find or findbyid.
With other mongo client I can use that _id also when ai save it as ObjectID or as string because mongoose convert it automatically. So, I think this is a typegoose issue.
This is a problem for that records that you have to save before run the app for configuring something on the db. In that case is usefull to use a known _id (as string). But, when the app is running, is usefull use the automatic ObjectID generation.
Hi.
I'm using yet typegoose 3.5.2 because 3.6.0 don't works for me (see #68).
I defined a model with the "_id" field to simplify the configuration of data on db. This is not frequently but it works and it is admitted with mongoose.
When I load in memory a doc defined with an array of items wich are defined with an "_id" field, the array is empty.
Below the source file.
The text was updated successfully, but these errors were encountered: