Auth user is not updating on a find
See original GitHub issueSteps to reproduce
First use the Auth plugin to authenticate to a feathers server.
Let the server only return basic user data: Let’s say the server respond with id
and displayname
fields only.
Setup your User model so that instanceDefault add a email
property with default value null
Later in the app, if you need all user data, using User.get(AUTH_USER_ID)
it will populate auth user with his email.
But if you use User.find({query:{id:AUTH_USER_ID}})
, email won’t get updated.
So, to give a small example, this is not working:
const users = (await Users.find({
query: {
$select: ['id', 'displayname', 'email'],
id: {
$in: userIds
}
}
})).data
whereas this one works (but it’s obviously not optimal)
const users = await Promise.all(userIds.map(async id => {
return await Users.get(id, {
query: {
$select: ['id', 'displayname', 'email']
}
})
}))
Expected behavior
User used in Auth plugin should have his properties updated on a find
as it does on a get
.
Actual behavior
The find query with the Auth user is like a No-op.
System configuration
NodeJS version: Electron 9.3
Operating System: Archlinux
Browser Version: Electron 9.3
React Native Version: No. Using Quasar 1.14
Module Loader: Webpack 4.44
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (3 by maintainers)
Top GitHub Comments
I finally found the Bug. And it’s not related to feathers-vuex. I post here the solution because it may affect others. Sometimes my backend server was sending “id” as
Number
and sometimes asString
. It turns out that’s because I use knex with postgresql. And Int8 field, Count and other functions return an int8 : 2^64 max value. As JS max int is 2^53, knex return thoses numbers asString
to avoid an overflow. Solution is as easy as doingBut be aware that an overflow become possible… if you have more that 9 Petabytes of entries in a single table!
Oh wow that’s going to be a great resource for somebody in the future, for sure. Thanks for sharing the solution.