I noted when I use the same instance for multiple actions on database, some queries just get in bug after first database operation.
Here I wrote an demo that I did an insert, findbyid and update but the update method throw an exception
TypeError: Cannot read property 'id' of undefined
at Object.get [as id] (/Users/italojs/dev/herbjs/herbs2knex/xp/node_modules/herbs2knex/src/dataMapper.js:121:48)
at Function.fromJSON (/Users/italojs/dev/herbjs/herbs2knex/xp/node_modules/gotu/src/baseEntity.js:119:96)
at DataMapper.toEntity (/Users/italojs/dev/herbjs/herbs2knex/xp/node_modules/herbs2knex/src/dataMapper.js:19:28)
at UserRepository.update (/Users/italojs/dev/herbjs/herbs2knex/xp/node_modules/herbs2knex/src/repository.js:164:28)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at async main (/Users/italojs/dev/herbjs/herbs2knex/xp/index.js:48:21)
I believe it can be an bug.
To solve it, basically we can
I noted when I use the same instance for multiple actions on database, some queries just get in bug after first database operation.
Here I wrote an demo that I did an
insert
,findbyid
andupdate
but the update method throw an exceptionI believe it can be an bug. To solve it, basically we can
Repository
Creates a new Knex Builder for each query like:
[...]