Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error During Migration #532

Open
arjunsaud opened this issue Oct 11, 2024 · 1 comment
Open

Error During Migration #532

arjunsaud opened this issue Oct 11, 2024 · 1 comment

Comments

@arjunsaud
Copy link

arjunsaud commented Oct 11, 2024

Error: MongooseError: document must have an _id before saving
at MigrationUserSeed.seeds (/home/anon/Desktop/All/blog-backend/src/migration/seeds/migration.user.seed.ts:71:19)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
 ELIFECYCLE  Command failed with exit code 1.


 I have changed this file


export abstract class DatabaseEntityAbstract {
    @DatabaseProp({
        type: String,
        default: new Types.ObjectId();  //added this
       //default: uuidV4, //removed this
    })
    _id: string;
@arjunsaud arjunsaud changed the title ReplyError: NOAUTH Authentication required. Error During Migration Oct 11, 2024
@andrechristikan
Copy link
Owner

andrechristikan commented Nov 5, 2024

if u want to change the _id to object id, u need to change the value of type in @DatabaseProp options too.
like this

 @DatabaseProp({
        type: Types.ObjectId,
        default: new Types.ObjectId(); 
    })
    _id: Types.ObjectId;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants