drizzle-team / drizzle-team/drizzle-orm
[FEATURE]: return a object instead of a array if insert value is a object not array
- Dominant language
- TypeScript
- Stars
- 35.8k
- Forks
- 1.6k
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 4
Description
### Describe what you want
Hi, I want to create a row, so I code this.
```ts
const model = await this.db.drizzle
.insert(schema.user)
.values({
authCode,
...userDto,
password: hashSync(userDto.password, 10),
})
.returning()
return model[0]
```
I added a `.returning` to get the new model. But I got `model[]`, to I should destruct it first. `model[0]` is the data I want. But I insert just a single object, so the expected result should be an object, which can save one step of writing.
This is the expected behaviour.
```ts
const model = await this.db.drizzle
.insert(schema.user)
.values({
authCode,
...userDto,
password: hashSync(userDto.password, 10),
})
.returning()
return model
```
Contributor guide
Assessment
This issue has not been assessed yet.