Skip to content

Commit 652902a

Browse files
authored
Merge pull request #220 from AthennaIO/develop
fix: adjust createOrUpdate type
2 parents ec1a7f4 + ffe9c0d commit 652902a

File tree

5 files changed

+6
-6
lines changed

5 files changed

+6
-6
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@athenna/database",
3-
"version": "5.39.0",
3+
"version": "5.40.0",
44
"description": "The Athenna database handler for SQL/NoSQL.",
55
"license": "MIT",
66
"author": "João Lenon <lenon@athenna.io>",

src/database/builders/QueryBuilder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ export class QueryBuilder<
252252
/**
253253
* Create data or update if already exists.
254254
*/
255-
public async createOrUpdate(data?: Partial<T>): Promise<T | T[]> {
255+
public async createOrUpdate(data?: Partial<T>): Promise<T> {
256256
return this.driver.createOrUpdate(data)
257257
}
258258

src/models/BaseModel.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ export class BaseModel {
426426
where: Partial<InstanceType<T>>,
427427
data: Partial<InstanceType<T>>,
428428
cleanPersist = true
429-
): Promise<InstanceType<T> | InstanceType<T>[]> {
429+
): Promise<InstanceType<T>> {
430430
const query = this.query()
431431

432432
if (where) {

src/models/builders/ModelQueryBuilder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ export class ModelQueryBuilder<
390390
if (hasValue) {
391391
const pk = this.primaryKeyProperty
392392

393-
return this.where(pk, hasValue[pk as any]).update(data, cleanPersist)
393+
return this.where(pk, hasValue[pk as any]).update(data, cleanPersist) as Promise<M>
394394
}
395395

396396
return this.create(data, cleanPersist)

0 commit comments

Comments
 (0)