brocoders / nestjs-boilerplate

NestJS boilerplate. Auth, TypeORM, Mongoose, Postgres, MongoDB, Mailing, I18N, Docker.
https://nestjs-boilerplate-test.herokuapp.com/docs
MIT License
3.17k stars 648 forks source link

add user field to file #1730

Closed isaachamid closed 1 month ago

isaachamid commented 1 month ago

Hi there, thanks for your great job,

how can i define user (created by) field to Products table in mongo?

Regards

Shchepotin commented 1 month ago

Hello @isaachamid

There are a couple of strategies for storage: duplication data (for good performance) and reference. Currently boilerplate has one example for a photo (duplication) https://github.com/brocoders/nestjs-boilerplate/blob/2cb1883d5a5c33125ae98d02bdbe9d050b808506/src/users/infrastructure/persistence/document/entities/user.schema.ts#L82-L89

But the same will be for references.

Also, we are working on CLI which will help create fields like this in a few seconds.