Closed JiPaix closed 1 year ago
ref
references a specific entry in your database, where query
searches an object collection by matching each child of the referenced path for given filter conditions.
You can simply use ref
:
const snapshot = await db.ref(`users/${userId}/allowed`).get();
const isAllowed = snapshot.val() === true;
If you want to query all users that have allowed
set to true
, use:
const allowedUsers = await db.query('users').filter('allowed', '==', true).get();
Kindly note that instead of rolling your own auth, you might want to use AceBase server's built-in auth. See https://github.com/appy-one/acebase-server and https://github.com/appy-one/acebase-client
Do you like AceBase? 👇🏼
This might just be me not understanding how AceBase works but i'm getting some weird results between
query()
andref()
A brief example of what's happening
Here's the whole context:
Then somewhere else in the code is called
UserDatabase.isAllowed