Create new user

Hello,
I have a little problem creating a new user.
I think it comes from the fact that it does not create my user in userdatas in addition to users.
The user is well registered in users but not in usersdatas

Here is my error:

[nodemon] restarting due to changes...
[nodemon] starting `node ./server.js localhost 3310`
Your admin panel is available here: https://app.forestadmin.com/projects
Your application is listening on port 3310.
OPTIONS /forest/users?fields%5Bcompagny%5D=name&fields%5BusersData%5D=fullName&fields%5Busers%5D=userId%2CusersData%2Cgender%2Cemail%2Ccompagny%2CfullNumber%2CemailValidated%2CcreatedAt&page%5Bnumber%5D=1&page%5Bsize%5D=15&searchExtended=0&sort=-createdAt&timezone=Europe%2FParis 204 0 - 7.702 ms
OPTIONS /forest/users/count?fields%5Busers%5D=userId%2CusersData%2Cgender%2Cemail%2Ccompagny%2CfullNumber%2CemailValidated%2CcreatedAt&fields%5BusersData%5D=fullName&fields%5Bcompagny%5D=name&searchExtended=0&timezone=Europe%2FParis 204 0 - 0.342 ms
GET /forest/users/count?fields%5Busers%5D=userId%2CusersData%2Cgender%2Cemail%2Ccompagny%2CfullNumber%2CemailValidated%2CcreatedAt&fields%5BusersData%5D=fullName&fields%5Bcompagny%5D=name&searchExtended=0&timezone=Europe%2FParis 304 - - 709.088 ms
GET /forest/users?fields%5Bcompagny%5D=name&fields%5BusersData%5D=fullName&fields%5Busers%5D=userId%2CusersData%2Cgender%2Cemail%2Ccompagny%2CfullNumber%2CemailValidated%2CcreatedAt&page%5Bnumber%5D=1&page%5Bsize%5D=15&searchExtended=0&sort=-createdAt&timezone=Europe%2FParis 304 - - 909.343 ms
OPTIONS /forest/compagnies?context%5Brecord%5D%5Btype%5D=user&context%5Brecord%5D%5Bid%5D=&fields%5Bcompagnies%5D=name&page%5Bnumber%5D=1&page%5Bsize%5D=100&searchToEdit=true&timezone=Europe%2FParis 204 0 - 0.151 ms
GET /forest/compagnies?context%5Brecord%5D%5Btype%5D=user&context%5Brecord%5D%5Bid%5D=&fields%5Bcompagnies%5D=name&page%5Bnumber%5D=1&page%5Bsize%5D=100&searchToEdit=true&timezone=Europe%2FParis 304 - - 74.876 ms
GET /forest/compagnies?context%5Brecord%5D%5Btype%5D=user&context%5Brecord%5D%5Bid%5D=&fields%5Bcompagnies%5D=name&page%5Bnumber%5D=1&page%5Bsize%5D=100&searchToEdit=true&timezone=Europe%2FParis 304 - - 43.649 ms
Unhandled rejection Error: WHERE parameter "userId" has invalid "undefined" value
    at MySQLQueryGenerator.whereItemQuery (/Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/dialects/abstract/query-generator.js:2085:13)
    at /Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/dialects/abstract/query-generator.js:2074:25
    at Array.forEach (<anonymous>)
    at MySQLQueryGenerator.whereItemsQuery (/Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/dialects/abstract/query-generator.js:2072:35)
    at MySQLQueryGenerator.getWhereConditions (/Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/dialects/abstract/query-generator.js:2484:19)
    at MySQLQueryGenerator.selectQuery (/Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/dialects/abstract/query-generator.js:1307:28)
    at QueryInterface.select (/Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/query-interface.js:1119:27)
    at /Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/model.js:1754:34
    at tryCatcher (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/promise.js:547:31)
    at Promise._settlePromise (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/promise.js:604:18)
    at Promise._settlePromise0 (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/promise.js:649:10)
    at Promise._settlePromises (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/promise.js:729:18)
    at _drainQueueStep (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/async.js:93:12)
    at _drainQueue (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/async.js:86:9)
    at Async._drainQueues (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/async.js:102:5)
    at Immediate.Async.drainQueues [as _onImmediate] (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/async.js:15:14)
    at processImmediate (internal/timers.js:456:21)
Unhandled rejection Error: WHERE parameter "userId" has invalid "undefined" value
    at MySQLQueryGenerator.whereItemQuery (/Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/dialects/abstract/query-generator.js:2085:13)
    at /Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/dialects/abstract/query-generator.js:2074:25
    at Array.forEach (<anonymous>)
    at MySQLQueryGenerator.whereItemsQuery (/Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/dialects/abstract/query-generator.js:2072:35)
    at MySQLQueryGenerator.whereQuery (/Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/dialects/abstract/query-generator.js:2045:24)
    at MySQLQueryGenerator.updateQuery (/Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/dialects/abstract/query-generator.js:435:116)
    at QueryInterface.bulkUpdate (/Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/query-interface.js:1038:37)
    at /Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/model.js:3219:34
    at tryCatcher (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/promise.js:547:31)
    at Promise._settlePromise (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/promise.js:604:18)
    at Promise._settlePromise0 (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/promise.js:649:10)
    at Promise._settlePromises (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/promise.js:729:18)
    at _drainQueueStep (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/async.js:93:12)
    at _drainQueue (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/async.js:86:9)
    at Async._drainQueues (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/async.js:102:5)
    at Immediate.Async.drainQueues [as _onImmediate] (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/async.js:15:14)
    at processImmediate (internal/timers.js:456:21)
Unhandled rejection Error: WHERE parameter "userId" has invalid "undefined" value
    at MySQLQueryGenerator.whereItemQuery (/Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/dialects/abstract/query-generator.js:2085:13)
    at /Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/dialects/abstract/query-generator.js:2074:25
    at Array.forEach (<anonymous>)
    at MySQLQueryGenerator.whereItemsQuery (/Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/dialects/abstract/query-generator.js:2072:35)
    at MySQLQueryGenerator.whereQuery (/Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/dialects/abstract/query-generator.js:2045:24)
    at MySQLQueryGenerator.updateQuery (/Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/dialects/abstract/query-generator.js:435:116)
    at QueryInterface.bulkUpdate (/Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/query-interface.js:1038:37)
    at /Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/model.js:3219:34
    at tryCatcher (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/promise.js:547:31)
    at Promise._settlePromise (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/promise.js:604:18)
    at Promise._settlePromise0 (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/promise.js:649:10)
    at Promise._settlePromises (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/promise.js:729:18)
    at _drainQueueStep (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/async.js:93:12)
    at _drainQueue (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/async.js:86:9)
    at Async._drainQueues (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/async.js:102:5)
    at Immediate.Async.drainQueues [as _onImmediate] (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/async.js:15:14)
    at processImmediate (internal/timers.js:456:21)
Unhandled rejection Error: WHERE parameter "userId" has invalid "undefined" value
    at MySQLQueryGenerator.whereItemQuery (/Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/dialects/abstract/query-generator.js:2085:13)
    at /Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/dialects/abstract/query-generator.js:2074:25
    at Array.forEach (<anonymous>)
    at MySQLQueryGenerator.whereItemsQuery (/Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/dialects/abstract/query-generator.js:2072:35)
    at MySQLQueryGenerator.whereQuery (/Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/dialects/abstract/query-generator.js:2045:24)
    at MySQLQueryGenerator.updateQuery (/Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/dialects/abstract/query-generator.js:435:116)
    at QueryInterface.bulkUpdate (/Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/query-interface.js:1038:37)
    at /Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/model.js:3219:34
    at tryCatcher (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/promise.js:547:31)
    at Promise._settlePromise (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/promise.js:604:18)
    at Promise._settlePromise0 (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/promise.js:649:10)
    at Promise._settlePromises (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/promise.js:729:18)
    at _drainQueueStep (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/async.js:93:12)
    at _drainQueue (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/async.js:86:9)
    at Async._drainQueues (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/async.js:102:5)
    at Immediate.Async.drainQueues [as _onImmediate] (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/async.js:15:14)
    at processImmediate (internal/timers.js:456:21)
Unhandled rejection Error: WHERE parameter "userId" has invalid "undefined" value
    at MySQLQueryGenerator.whereItemQuery (/Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/dialects/abstract/query-generator.js:2085:13)
    at /Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/dialects/abstract/query-generator.js:2074:25
    at Array.forEach (<anonymous>)
    at MySQLQueryGenerator.whereItemsQuery (/Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/dialects/abstract/query-generator.js:2072:35)
    at MySQLQueryGenerator.whereQuery (/Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/dialects/abstract/query-generator.js:2045:24)
    at MySQLQueryGenerator.updateQuery (/Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/dialects/abstract/query-generator.js:435:116)
    at QueryInterface.bulkUpdate (/Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/query-interface.js:1038:37)
    at /Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/model.js:3219:34
    at tryCatcher (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/promise.js:547:31)
    at Promise._settlePromise (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/promise.js:604:18)
    at Promise._settlePromise0 (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/promise.js:649:10)
    at Promise._settlePromises (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/promise.js:729:18)
    at _drainQueueStep (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/async.js:93:12)
    at _drainQueue (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/async.js:86:9)
    at Async._drainQueues (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/async.js:102:5)
    at Immediate.Async.drainQueues [as _onImmediate] (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/async.js:15:14)
    at processImmediate (internal/timers.js:456:21)
Unhandled rejection Error: WHERE parameter "userId" has invalid "undefined" value
    at MySQLQueryGenerator.whereItemQuery (/Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/dialects/abstract/query-generator.js:2085:13)
    at /Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/dialects/abstract/query-generator.js:2074:25
    at Array.forEach (<anonymous>)
    at MySQLQueryGenerator.whereItemsQuery (/Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/dialects/abstract/query-generator.js:2072:35)
    at MySQLQueryGenerator.whereQuery (/Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/dialects/abstract/query-generator.js:2045:24)
    at MySQLQueryGenerator.updateQuery (/Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/dialects/abstract/query-generator.js:435:116)
    at QueryInterface.bulkUpdate (/Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/query-interface.js:1038:37)
    at /Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/model.js:3219:34
    at tryCatcher (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/promise.js:547:31)
    at Promise._settlePromise (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/promise.js:604:18)
    at Promise._settlePromise0 (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/promise.js:649:10)
    at Promise._settlePromises (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/promise.js:729:18)
    at _drainQueueStep (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/async.js:93:12)
    at _drainQueue (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/async.js:86:9)
    at Async._drainQueues (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/async.js:102:5)
    at Immediate.Async.drainQueues [as _onImmediate] (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/async.js:15:14)
    at processImmediate (internal/timers.js:456:21)
Unhandled rejection Error: WHERE parameter "userId" has invalid "undefined" value
    at MySQLQueryGenerator.whereItemQuery (/Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/dialects/abstract/query-generator.js:2085:13)
    at /Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/dialects/abstract/query-generator.js:2074:25
    at Array.forEach (<anonymous>)
    at MySQLQueryGenerator.whereItemsQuery (/Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/dialects/abstract/query-generator.js:2072:35)
    at MySQLQueryGenerator.whereQuery (/Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/dialects/abstract/query-generator.js:2045:24)
    at MySQLQueryGenerator.updateQuery (/Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/dialects/abstract/query-generator.js:435:116)
    at QueryInterface.bulkUpdate (/Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/query-interface.js:1038:37)
    at /Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/model.js:3219:34
    at tryCatcher (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/promise.js:547:31)
    at Promise._settlePromise (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/promise.js:604:18)
    at Promise._settlePromise0 (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/promise.js:649:10)
    at Promise._settlePromises (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/promise.js:729:18)
    at _drainQueueStep (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/async.js:93:12)
    at _drainQueue (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/async.js:86:9)
    at Async._drainQueues (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/async.js:102:5)
    at Immediate.Async.drainQueues [as _onImmediate] (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/async.js:15:14)
    at processImmediate (internal/timers.js:456:21)
Unhandled rejection Error: WHERE parameter "userId" has invalid "undefined" value
    at MySQLQueryGenerator.whereItemQuery (/Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/dialects/abstract/query-generator.js:2085:13)
    at /Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/dialects/abstract/query-generator.js:2074:25
    at Array.forEach (<anonymous>)
    at MySQLQueryGenerator.whereItemsQuery (/Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/dialects/abstract/query-generator.js:2072:35)
    at MySQLQueryGenerator.whereQuery (/Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/dialects/abstract/query-generator.js:2045:24)
    at MySQLQueryGenerator.updateQuery (/Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/dialects/abstract/query-generator.js:435:116)
    at QueryInterface.bulkUpdate (/Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/query-interface.js:1038:37)
    at /Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/model.js:3219:34
    at tryCatcher (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/promise.js:547:31)
    at Promise._settlePromise (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/promise.js:604:18)
    at Promise._settlePromise0 (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/promise.js:649:10)
    at Promise._settlePromises (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/promise.js:729:18)
    at _drainQueueStep (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/async.js:93:12)
    at _drainQueue (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/async.js:86:9)
    at Async._drainQueues (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/async.js:102:5)
    at Immediate.Async.drainQueues [as _onImmediate] (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/async.js:15:14)
    at processImmediate (internal/timers.js:456:21)
POST /forest/users 200 1537 - 127.705 ms
OPTIONS /forest/users/31 204 0 - 1.315 ms
GET /forest/users/31 200 1537 - 17.296 ms
GET /forest/users?fields%5Bcompagny%5D=name&fields%5BusersData%5D=fullName&fields%5Busers%5D=userId%2CusersData%2Cgender%2Cemail%2Ccompagny%2CfullNumber%2CemailValidated%2CcreatedAt&page%5Bnumber%5D=1&page%5Bsize%5D=15&searchExtended=0&sort=-createdAt&timezone=Europe%2FParis 200 3461 - 210.322 ms
GET /forest/users/count?fields%5Busers%5D=userId%2CusersData%2Cgender%2Cemail%2Ccompagny%2CfullNumber%2CemailValidated%2CcreatedAt&fields%5BusersData%5D=fullName&fields%5Bcompagny%5D=name&searchExtended=0&timezone=Europe%2FParis 200 11 - 108.123 ms
GET /forest/users/count?fields%5Busers%5D=userId%2CusersData%2Cgender%2Cemail%2Ccompagny%2CfullNumber%2CemailValidated%2CcreatedAt&fields%5BusersData%5D=fullName&fields%5Bcompagny%5D=name&searchExtended=0&timezone=Europe%2FParis 200 11 - 98.083 ms
GET /forest/users/count?fields%5Busers%5D=userId%2CusersData%2Cgender%2Cemail%2Ccompagny%2CfullNumber%2CemailValidated%2CcreatedAt&fields%5BusersData%5D=fullName&fields%5Bcompagny%5D=name&searchExtended=0&timezone=Europe%2FParis 200 11 - 103.298 ms
GET /forest/users/count?fields%5Busers%5D=userId%2CusersData%2Cgender%2Cemail%2Ccompagny%2CfullNumber%2CemailValidated%2CcreatedAt&fields%5BusersData%5D=fullName&fields%5Bcompagny%5D=name&searchExtended=0&timezone=Europe%2FParis 200 11 - 304.366 ms
GET /forest/users/count?fields%5Busers%5D=userId%2CusersData%2Cgender%2Cemail%2Ccompagny%2CfullNumber%2CemailValidated%2CcreatedAt&fields%5BusersData%5D=fullName&fields%5Bcompagny%5D=name&searchExtended=0&timezone=Europe%2FParis 200 11 - 305.641 ms
GET /forest/users/count?fields%5Busers%5D=userId%2CusersData%2Cgender%2Cemail%2Ccompagny%2CfullNumber%2CemailValidated%2CcreatedAt&fields%5BusersData%5D=fullName&fields%5Bcompagny%5D=name&searchExtended=0&timezone=Europe%2FParis 200 11 - 265.395 ms
GET /forest/users/count?fields%5Busers%5D=userId%2CusersData%2Cgender%2Cemail%2Ccompagny%2CfullNumber%2CemailValidated%2CcreatedAt&fields%5BusersData%5D=fullName&fields%5Bcompagny%5D=name&searchExtended=0&timezone=Europe%2FParis 200 11 - 265.257 ms
GET /forest/users/count?fields%5Busers%5D=userId%2CusersData%2Cgender%2Cemail%2Ccompagny%2CfullNumber%2CemailValidated%2CcreatedAt&fields%5BusersData%5D=fullName&fields%5Bcompagny%5D=name&searchExtended=0&timezone=Europe%2FParis 200 11 - 268.513 ms
GET /forest/users/count?fields%5Busers%5D=userId%2CusersData%2Cgender%2Cemail%2Ccompagny%2CfullNumber%2CemailValidated%2CcreatedAt&fields%5BusersData%5D=fullName&fields%5Bcompagny%5D=name&searchExtended=0&timezone=Europe%2FParis 200 11 - 268.079 ms

Here are my models:
users.js

// This model was generated by Lumber. However, you remain in control of your models.
// Learn how here: https://docs.forestadmin.com/documentation/v/v5/reference-guide/models/enrich-your-models
module.exports = (sequelize, DataTypes) => {
  const { Sequelize } = sequelize;
  const ClassCrisp = require('../Class/Crisp');
  const Crisp = new ClassCrisp();
  // This section contains the fields of your model, mapped to your table's columns.
  // Learn more here: https://docs.forestadmin.com/documentation/v/v5/reference-guide/models/enrich-your-models#declaring-a-new-field-in-a-model
  const Users = sequelize.define('users', {
    userId: {
      type: DataTypes.BIGINT,
      primaryKey: true,
      autoIncrement: true
    },
    compId: {
      type: DataTypes.BIGINT,
    },
    email: {
      type: DataTypes.STRING,
    },
    password: {
      type: DataTypes.STRING,
    },
    indicMobile: {
      type: DataTypes.STRING,
    },
    mobile: {
      type: DataTypes.STRING,
    },
    stripeId: {
      type: DataTypes.STRING,
    },
    crispId: {
      type: DataTypes.STRING,
    },
    blocked: {
      type: DataTypes.BOOLEAN,
      defaultValue: Sequelize.literal('0'),
    },
    createdAt: {
      type: DataTypes.DATE,
      defaultValue: Sequelize.literal('CURRENT_TIMESTAMP'),
    },
    updatedAt: {
      type: DataTypes.DATE,
      defaultValue: Sequelize.literal('CURRENT_TIMESTAMP'),
    },
  }, {
    tableName: 'users',
    hooks: {
      afterUpdate: async (user) => {
        if (user.dataValues.compId != user._previousDataValues.compId) {
          await sequelize.models.users.findOne({
            where: { userId: user.dataValues.userId },
            include: [{
              model: sequelize.models.usersDatas
            }]
          }).then(async (user) => {
            await sequelize.models.compagnies.findOne({
              where: { compId: user.dataValues.compId }
            }).then((company) => {
              console.log(user.usersData);
              user.usersData.update({
                defaultLoc: 0
              });
              Crisp.updateUserCompany(user, company);
            });
          });
        }
        return user;
      }
    }
  });
  // This section contains the relationships for this model. See: https://docs.forestadmin.com/documentation/v/v5/reference-guide/relationships#adding-relationships.
  Users.associate = (models) => {
    Users.hasOne(models.usersDatas, {
      foreignKey: 'userId'
    });
    Users.hasMany(models.orders, {
      foreignKey: 'userId'
    });
    Users.belongsTo(models.compagnies, {
      foreignKey: 'compId'
    });
  };
  return Users;
};

users-datas.js

// This model was generated by Lumber. However, you remain in control of your models.
// Learn how here: https://docs.forestadmin.com/documentation/v/v5/reference-guide/models/enrich-your-models
module.exports = (sequelize, DataTypes) => {
  const { Sequelize } = sequelize;
  // This section contains the fields of your model, mapped to your table's columns.
  // Learn more here: https://docs.forestadmin.com/documentation/v/v5/reference-guide/models/enrich-your-models#declaring-a-new-field-in-a-model
  const UsersDatas = sequelize.define('usersDatas', {
    userId: {
      type: DataTypes.BIGINT,
      primaryKey: true,
    },
    defaultLoc: {
      type: DataTypes.BIGINT,
    },
    firstName: {
      type: DataTypes.STRING,
    },
    lastName: {
      type: DataTypes.STRING,
    },
    dateOfBirth: {
      type: DataTypes.DATE,
    },
    gender: {
      type: DataTypes.INTEGER,
    },
    adresse: {
      type: DataTypes.STRING,
    },
    city: {
      type: DataTypes.STRING,
    },
    zipCode: {
      type: DataTypes.INTEGER,
    },
    country: {
      type: DataTypes.STRING,
    },
    language: {
      type: DataTypes.STRING,
      defaultValue: Sequelize.literal('en_US'),
    },
    emailValidated: {
      type: DataTypes.STRING,
      defaultValue: Sequelize.literal('error'),
    },
    emailValidatedExp: {
      type: DataTypes.DATE,
      defaultValue: Sequelize.literal('CURRENT_TIMESTAMP'),
    },
    resetPassword: {
      type: DataTypes.STRING,
    },
    resetPasswordExp: {
      type: DataTypes.DATE,
    },
    createdAt: {
      type: DataTypes.DATE,
      defaultValue: Sequelize.literal('CURRENT_TIMESTAMP'),
    },
    updatedAt: {
      type: DataTypes.DATE,
      defaultValue: Sequelize.literal('CURRENT_TIMESTAMP'),
    },
  }, {
    tableName: 'usersDatas',
  });
  // This section contains the relationships for this model. See: https://docs.forestadmin.com/documentation/v/v5/reference-guide/relationships#adding-relationships.
  UsersDatas.associate = (models) => {
    UsersDatas.belongsTo(models.users, {
      foreignKey: 'userId'
    });
  };
  return UsersDatas;
};

Here is my route:

// Create a User
router.post('/users', permissionMiddlewareCreator.create(), (request, response, next) => {
  const recordCreator = new RecordCreator(users);
  recordCreator.deserialize(request.body)
      .then(recordToCreate => recordCreator.create(recordToCreate))
      .then(record => recordCreator.serialize(record))
      .then(recordSerialized => response.send(recordSerialized))
      .catch(next);
});

Hi @Benjamin
Welcome in the Forest community!

Do you have the same error if you deactivate your custom afterUpdate users model hook?

Hi @arnaud
Thank’s

const Users = sequelize.define('users', {
    userId: {
      type: DataTypes.BIGINT,
      primaryKey: true,
      autoIncrement: true
    },
    compId: {
      type: DataTypes.BIGINT,
    },
    email: {
      type: DataTypes.STRING,
    },
    password: {
      type: DataTypes.STRING,
    },
    indicMobile: {
      type: DataTypes.STRING,
    },
    mobile: {
      type: DataTypes.STRING,
    },
    stripeId: {
      type: DataTypes.STRING,
    },
    crispId: {
      type: DataTypes.STRING,
    },
    blocked: {
      type: DataTypes.BOOLEAN,
      defaultValue: Sequelize.literal('0'),
    },
    createdAt: {
      type: DataTypes.DATE,
      defaultValue: Sequelize.literal('CURRENT_TIMESTAMP'),
    },
    updatedAt: {
      type: DataTypes.DATE,
      defaultValue: Sequelize.literal('CURRENT_TIMESTAMP'),
    },
  }, {
    tableName: 'users',
    // hooks: {
    //   afterUpdate: async (user) => {
    //     if (user.dataValues.compId != user._previousDataValues.compId) {
    //       await sequelize.models.users.findOne({
    //         where: { userId: user.dataValues.userId },
    //         include: [{
    //           model: sequelize.models.usersDatas
    //         }]
    //       }).then(async (user) => {
    //         await sequelize.models.compagnies.findOne({
    //           where: { compId: user.dataValues.compId }
    //         }).then((company) => {
    //           console.log(user.usersData);
    //           user.usersData.update({
    //             defaultLoc: 0
    //           });
    //           Crisp.updateUserCompany(user, company);
    //         });
    //       });
    //     }
    //     return user;
    //   }
    // }
  });

I comment on my hook but I still have this error :

[nodemon] restarting due to changes...
[nodemon] starting `node ./server.js localhost 3310`
Your admin panel is available here: https://app.forestadmin.com/projects
Your application is listening on port 3310.
GET /forest/users?fields%5Bcompagny%5D=name&fields%5BusersData%5D=fullName&fields%5Busers%5D=userId%2CusersData%2Cgender%2Cemail%2Ccompagny%2CfullNumber%2CemailValidated%2CcreatedAt&page%5Bnumber%5D=1&page%5Bsize%5D=15&searchExtended=0&sort=-createdAt&timezone=Europe%2FParis 200 2045 - 492.573 ms
GET /forest/users/count?fields%5Busers%5D=userId%2CusersData%2Cgender%2Cemail%2Ccompagny%2CfullNumber%2CemailValidated%2CcreatedAt&fields%5BusersData%5D=fullName&fields%5Bcompagny%5D=name&searchExtended=0&timezone=Europe%2FParis 200 11 - 341.151 ms
GET /forest/compagnies?context%5Brecord%5D%5Btype%5D=user&context%5Brecord%5D%5Bid%5D=&fields%5Bcompagnies%5D=name&page%5Bnumber%5D=1&page%5Bsize%5D=100&searchToEdit=true&timezone=Europe%2FParis 304 - - 22.129 ms
GET /forest/compagnies?context%5Brecord%5D%5Btype%5D=user&context%5Brecord%5D%5Bid%5D=&fields%5Bcompagnies%5D=name&page%5Bnumber%5D=1&page%5Bsize%5D=100&searchToEdit=true&timezone=Europe%2FParis 304 - - 25.984 ms
Unhandled rejection Error: WHERE parameter "userId" has invalid "undefined" value
    at MySQLQueryGenerator.whereItemQuery (/Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/dialects/abstract/query-generator.js:2085:13)
    at /Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/dialects/abstract/query-generator.js:2074:25
    at Array.forEach (<anonymous>)
    at MySQLQueryGenerator.whereItemsQuery (/Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/dialects/abstract/query-generator.js:2072:35)
    at MySQLQueryGenerator.getWhereConditions (/Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/dialects/abstract/query-generator.js:2484:19)
    at MySQLQueryGenerator.selectQuery (/Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/dialects/abstract/query-generator.js:1307:28)
    at QueryInterface.select (/Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/query-interface.js:1119:27)
    at /Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/model.js:1754:34
    at tryCatcher (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/promise.js:547:31)
    at Promise._settlePromise (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/promise.js:604:18)
    at Promise._settlePromise0 (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/promise.js:649:10)
    at Promise._settlePromises (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/promise.js:729:18)
    at _drainQueueStep (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/async.js:93:12)
    at _drainQueue (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/async.js:86:9)
    at Async._drainQueues (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/async.js:102:5)
    at Immediate.Async.drainQueues [as _onImmediate] (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/async.js:15:14)
    at processImmediate (internal/timers.js:456:21)

Unhandled rejection Error: WHERE parameter "userId" has invalid "undefined" value
    at MySQLQueryGenerator.whereItemQuery (/Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/dialects/abstract/query-generator.js:2085:13)
    at /Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/dialects/abstract/query-generator.js:2074:25
    at Array.forEach (<anonymous>)
    at MySQLQueryGenerator.whereItemsQuery (/Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/dialects/abstract/query-generator.js:2072:35)
    at MySQLQueryGenerator.whereQuery (/Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/dialects/abstract/query-generator.js:2045:24)
    at MySQLQueryGenerator.updateQuery (/Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/dialects/abstract/query-generator.js:435:116)
    at QueryInterface.bulkUpdate (/Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/query-interface.js:1038:37)
    at /Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/model.js:3219:34
    at tryCatcher (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/promise.js:547:31)
    at Promise._settlePromise (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/promise.js:604:18)
    at Promise._settlePromise0 (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/promise.js:649:10)
    at Promise._settlePromises (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/promise.js:729:18)
    at _drainQueueStep (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/async.js:93:12)
    at _drainQueue (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/async.js:86:9)
    at Async._drainQueues (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/async.js:102:5)
    at Immediate.Async.drainQueues [as _onImmediate] (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/async.js:15:14)
    at processImmediate (internal/timers.js:456:21)

Unhandled rejection Error: WHERE parameter "userId" has invalid "undefined" value
    at MySQLQueryGenerator.whereItemQuery (/Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/dialects/abstract/query-generator.js:2085:13)
    at /Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/dialects/abstract/query-generator.js:2074:25
    at Array.forEach (<anonymous>)
    at MySQLQueryGenerator.whereItemsQuery (/Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/dialects/abstract/query-generator.js:2072:35)
    at MySQLQueryGenerator.whereQuery (/Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/dialects/abstract/query-generator.js:2045:24)
    at MySQLQueryGenerator.updateQuery (/Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/dialects/abstract/query-generator.js:435:116)
    at QueryInterface.bulkUpdate (/Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/query-interface.js:1038:37)
    at /Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/model.js:3219:34
    at tryCatcher (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/promise.js:547:31)
    at Promise._settlePromise (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/promise.js:604:18)
    at Promise._settlePromise0 (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/promise.js:649:10)
    at Promise._settlePromises (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/promise.js:729:18)
    at _drainQueueStep (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/async.js:93:12)
    at _drainQueue (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/async.js:86:9)
    at Async._drainQueues (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/async.js:102:5)
    at Immediate.Async.drainQueues [as _onImmediate] (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/async.js:15:14)
    at processImmediate (internal/timers.js:456:21)

Unhandled rejection Error: WHERE parameter "userId" has invalid "undefined" value
    at MySQLQueryGenerator.whereItemQuery (/Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/dialects/abstract/query-generator.js:2085:13)
    at /Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/dialects/abstract/query-generator.js:2074:25
    at Array.forEach (<anonymous>)
    at MySQLQueryGenerator.whereItemsQuery (/Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/dialects/abstract/query-generator.js:2072:35)
    at MySQLQueryGenerator.whereQuery (/Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/dialects/abstract/query-generator.js:2045:24)
    at MySQLQueryGenerator.updateQuery (/Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/dialects/abstract/query-generator.js:435:116)
    at QueryInterface.bulkUpdate (/Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/query-interface.js:1038:37)
    at /Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/model.js:3219:34
    at tryCatcher (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/promise.js:547:31)
    at Promise._settlePromise (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/promise.js:604:18)
    at Promise._settlePromise0 (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/promise.js:649:10)
    at Promise._settlePromises (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/promise.js:729:18)
    at _drainQueueStep (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/async.js:93:12)
    at _drainQueue (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/async.js:86:9)
    at Async._drainQueues (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/async.js:102:5)
    at Immediate.Async.drainQueues [as _onImmediate] (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/async.js:15:14)
    at processImmediate (internal/timers.js:456:21)

Unhandled rejection Error: WHERE parameter "userId" has invalid "undefined" value
    at MySQLQueryGenerator.whereItemQuery (/Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/dialects/abstract/query-generator.js:2085:13)
    at /Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/dialects/abstract/query-generator.js:2074:25
    at Array.forEach (<anonymous>)
    at MySQLQueryGenerator.whereItemsQuery (/Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/dialects/abstract/query-generator.js:2072:35)
    at MySQLQueryGenerator.whereQuery (/Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/dialects/abstract/query-generator.js:2045:24)
    at MySQLQueryGenerator.updateQuery (/Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/dialects/abstract/query-generator.js:435:116)
    at QueryInterface.bulkUpdate (/Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/query-interface.js:1038:37)
    at /Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/model.js:3219:34
    at tryCatcher (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/promise.js:547:31)
    at Promise._settlePromise (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/promise.js:604:18)
    at Promise._settlePromise0 (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/promise.js:649:10)
    at Promise._settlePromises (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/promise.js:729:18)
    at _drainQueueStep (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/async.js:93:12)
    at _drainQueue (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/async.js:86:9)
    at Async._drainQueues (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/async.js:102:5)
    at Immediate.Async.drainQueues [as _onImmediate] (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/async.js:15:14)
    at processImmediate (internal/timers.js:456:21)

Unhandled rejection Error: WHERE parameter "userId" has invalid "undefined" value
    at MySQLQueryGenerator.whereItemQuery (/Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/dialects/abstract/query-generator.js:2085:13)
    at /Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/dialects/abstract/query-generator.js:2074:25
    at Array.forEach (<anonymous>)
    at MySQLQueryGenerator.whereItemsQuery (/Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/dialects/abstract/query-generator.js:2072:35)
    at MySQLQueryGenerator.whereQuery (/Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/dialects/abstract/query-generator.js:2045:24)
    at MySQLQueryGenerator.updateQuery (/Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/dialects/abstract/query-generator.js:435:116)
    at QueryInterface.bulkUpdate (/Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/query-interface.js:1038:37)
    at /Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/model.js:3219:34
    at tryCatcher (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/promise.js:547:31)
    at Promise._settlePromise (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/promise.js:604:18)
    at Promise._settlePromise0 (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/promise.js:649:10)
    at Promise._settlePromises (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/promise.js:729:18)
    at _drainQueueStep (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/async.js:93:12)
    at _drainQueue (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/async.js:86:9)
    at Async._drainQueues (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/async.js:102:5)
    at Immediate.Async.drainQueues [as _onImmediate] (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/async.js:15:14)
    at processImmediate (internal/timers.js:456:21)

Unhandled rejection Error: WHERE parameter "userId" has invalid "undefined" value
    at MySQLQueryGenerator.whereItemQuery (/Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/dialects/abstract/query-generator.js:2085:13)
    at /Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/dialects/abstract/query-generator.js:2074:25
    at Array.forEach (<anonymous>)
    at MySQLQueryGenerator.whereItemsQuery (/Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/dialects/abstract/query-generator.js:2072:35)
    at MySQLQueryGenerator.whereQuery (/Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/dialects/abstract/query-generator.js:2045:24)
    at MySQLQueryGenerator.updateQuery (/Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/dialects/abstract/query-generator.js:435:116)
    at QueryInterface.bulkUpdate (/Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/query-interface.js:1038:37)
    at /Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/model.js:3219:34
    at tryCatcher (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/promise.js:547:31)
    at Promise._settlePromise (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/promise.js:604:18)
    at Promise._settlePromise0 (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/promise.js:649:10)
    at Promise._settlePromises (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/promise.js:729:18)
    at _drainQueueStep (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/async.js:93:12)
    at _drainQueue (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/async.js:86:9)
    at Async._drainQueues (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/async.js:102:5)
    at Immediate.Async.drainQueues [as _onImmediate] (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/async.js:15:14)
    at processImmediate (internal/timers.js:456:21)

Unhandled rejection Error: WHERE parameter "userId" has invalid "undefined" value
    at MySQLQueryGenerator.whereItemQuery (/Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/dialects/abstract/query-generator.js:2085:13)
    at /Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/dialects/abstract/query-generator.js:2074:25
    at Array.forEach (<anonymous>)
    at MySQLQueryGenerator.whereItemsQuery (/Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/dialects/abstract/query-generator.js:2072:35)
    at MySQLQueryGenerator.whereQuery (/Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/dialects/abstract/query-generator.js:2045:24)
    at MySQLQueryGenerator.updateQuery (/Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/dialects/abstract/query-generator.js:435:116)
    at QueryInterface.bulkUpdate (/Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/query-interface.js:1038:37)
    at /Users/bvelluet/Git/Alfred/node_modules/sequelize/lib/model.js:3219:34
    at tryCatcher (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/promise.js:547:31)
    at Promise._settlePromise (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/promise.js:604:18)
    at Promise._settlePromise0 (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/promise.js:649:10)
    at Promise._settlePromises (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/promise.js:729:18)
    at _drainQueueStep (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/async.js:93:12)
    at _drainQueue (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/async.js:86:9)
    at Async._drainQueues (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/async.js:102:5)
    at Immediate.Async.drainQueues [as _onImmediate] (/Users/bvelluet/Git/Alfred/node_modules/sequelize/node_modules/bluebird/js/release/async.js:15:14)
    at processImmediate (internal/timers.js:456:21)

POST /forest/users 200 1510 - 123.493 ms
OPTIONS /forest/users/33 204 0 - 0.291 ms
GET /forest/users/33 200 1510 - 59.888 ms
GET /forest/users?fields%5Bcompagny%5D=name&fields%5BusersData%5D=fullName&fields%5Busers%5D=userId%2CusersData%2Cgender%2Cemail%2Ccompagny%2CfullNumber%2CemailValidated%2CcreatedAt&page%5Bnumber%5D=1&page%5Bsize%5D=15&searchExtended=0&sort=-createdAt&timezone=Europe%2FParis 200 3434 - 23.777 ms
GET /forest/users/count?fields%5Busers%5D=userId%2CusersData%2Cgender%2Cemail%2Ccompagny%2CfullNumber%2CemailValidated%2CcreatedAt&fields%5BusersData%5D=fullName&fields%5Bcompagny%5D=name&searchExtended=0&timezone=Europe%2FParis 200 11 - 72.704 ms

Ok thanks!

We need to isolate the origin of this error.
To continue the investigations, can you try to comment out the hasOne “userDatas” association in your “users” model.

Always the same error…

The idea is to reduce the quantity of code in your users model to find a spot where your users would be created without error.

Can you try to:

  • comment out all other users association and then give it another try?
  • if it is still present, continue to comment out your users fields declaration, and give it another try.

Ok the problem comes from forest/users.js

collection('users', {
  actions: [{
    name: 'Valider l\'email',
    type: 'single',
    endpoint: '/forest/users/actions/validateEmail',
  }],
  fields: [{
    field: 'fullNumber',
    type: 'String',
    get: (user) => {
      return '+' + user.indicMobile + user.mobile;
    },
    set: (user, fullNumber) => {
      fullNumber = fullNumber.replace(/\s/g,"");
      let indicMobile;
      let mobile;
      if (fullNumber[0] === '0') {
        indicMobile = '33';
        mobile = fullNumber.substr(1, fullNumber.length);
      } else {
        let number = fullNumber.substr(1, fullNumber.length);
        let numberRev = number.split('').reverse().join('');
        indicMobile = numberRev.substr(9, numberRev.length).split('').reverse().join('');
        mobile = numberRev.substr(0, 9).split('').reverse().join('');
      }
      users.findOne({
        where: { userId: user.userId }
      }).then((user) => {
        CrispClient.websitePeople.updatePeopleProfile(process.env.CRISP_WEBSITE_ID, user.crispId, {
          person: {
            phone: '+' + indicMobile + mobile
          }
        });
        stripe.customers.update(user.dataValues.stripeId, {
          phone: '+' + indicMobile + mobile
        });
      });
      user.indicMobile = indicMobile;
      user.mobile = mobile;
      return user;
    },
    search: function (query, search) {
      let split = search.split(' ');
      if (search[0] === '0') {
        search = search.substr(1, search.length);
      } else if (search[0] === '+') {
        search = search.substr(3, search.length);
      }
      var searchCondition = {
        [Op.and]: [
          { mobile: { [Op.like]: `%${search}%` } },
        ],
      };

      var fullNameCondition = {
        [Op.or]: [
          { '$usersData.firstName$': { [Op.like]: `%${split[0]}%` } },
          { '$usersData.lastName$': { [Op.like]: `%${split[1]}%` } },
          { '$usersData.firstName$': { [Op.like]: `%${split[1]}%` } },
          { '$usersData.lastName$': { [Op.like]: `%${split[0]}%` } },
        ]
      };
      query.where[Op.and][0][Op.or].push(searchCondition);
      query.where[Op.and][0][Op.or].push(fullNameCondition);

      return query;
    }
  }],
  segments: [],
});

This comes from the fullNumber, is there an incompatibility?

Ok so if it comes from the fullNumber Smart Field setter.
If you comment out the setter, even after all the associations re-activation, you don’t have any issue anymore?

What do you mean by incompatibility?
My understanding is that the setter runs on a user creation and the setter logic does not work you would expect. You’ll need to dig into you code customisation :wink:

One obvious thing is that users.findOne is an asynchronous operation but you don’t wait for it in the setter to do your final operations.
It might be the reason why the user is created and you have error logs after the creation.

OK actually I think I misunderstood the operation.

Is there a way to differentiate the set when it is a modification and when it is a creation?
In fact during a modification I made a call to “Crisp” (An integration), thing that I do not wish to do in that of creation …

set: (user, fullNumber) => {
      fullNumber = fullNumber.replace(/\s/g,"");
      let indicMobile;
      let mobile;
      if (fullNumber[0] === '0') {
        indicMobile = '33';
        mobile = fullNumber.substr(1, fullNumber.length);
      } else {
        let number = fullNumber.substr(1, fullNumber.length);
        let numberRev = number.split('').reverse().join('');
        indicMobile = numberRev.substr(9, numberRev.length).split('').reverse().join('');
        mobile = numberRev.substr(0, 9).split('').reverse().join('');
      }
      // users.findOne({
      //   where: { userId: user.userId }
      // }).then((user) => {
      //   CrispClient.websitePeople.updatePeopleProfile(process.env.CRISP_WEBSITE_ID, user.crispId, {
      //     person: {
      //       phone: '+' + indicMobile + mobile
      //     }
      //   });
      //   stripe.customers.update(user.dataValues.stripeId, {
      //     phone: '+' + indicMobile + mobile
      //   });
      // });
      user.indicMobile = indicMobile;
      user.mobile = mobile;
      return user;
    },

Thank’s :slight_smile:

Maybe a workaround to detect if you are in a create or update context is the presence of the user.userId value.
I think the initial error message confirms this.

Ok good !
Problem solved, thank you very much

1 Like