Skip to content
Snippets Groups Projects
Commit 14c688e9 authored by Yannis Barlas's avatar Yannis Barlas
Browse files

feat(models): base model delete by ids returns number of affected rows

BREAKING CHANGE:
deleteByIds does not return ids but number of rows now
parent 467ef396
No related branches found
No related tags found
1 merge request!123v4
......@@ -303,7 +303,7 @@ describe('Base model', () => {
const newEntity2 = await Fake.insert({})
const affectedRows = await Fake.deleteByIds([newEntity1.id, newEntity2.id])
const { result } = await Fake.find({})
expect(affectedRows).toEqual([newEntity1.id, newEntity2.id])
expect(affectedRows).toEqual(2)
expect(result).toHaveLength(0)
})
......
......@@ -363,7 +363,7 @@ class BaseModel extends Model {
.whereIn('id', ids)
.returning('id')
return result.map(u => u.id)
return result.length
} catch (e) {
logger.error(`${this.name} model: deleteByIds failed`, e)
throw new Error(e)
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment