knaadh / nestjs-drizzle

A NestJS module for integrating DrizzleORM with Postgres, MySQL, SQLite, Turso and Planetscale drivers
MIT License
114 stars 6 forks source link

When I insert, I only create a user ID #17

Closed Weronnip closed 1 month ago

Weronnip commented 1 month ago

My code: async createUser(@Body() createUserDto: CreateUserDto) { const newUser = await this.drizzleTrello .insert(schema.Users) .values({ data: createUserDto }); return { newUser: newUser, }; }

{ "newUser": [ { "fieldCount": 0, "affectedRows": 1, "insertId": 27, "info": "", "serverStatus": 2, "warningStatus": 0, "changedRows": 0 }, null ] }

mithleshjs commented 1 month ago

It is because you are not using returning as described here - https://orm.drizzle.team/docs/insert#insert-returning

The scope of this package is only to integrate Drizzle in NestJS. Please ask Drizzle related queries in its repo 🙏