Closed shaunnez closed 5 years ago
Hi,
Can you please give me an example of how your data is set up? The filters
property will be applied server-side (in Firestore self), so it won't know about the populate
d data yet - that only happens after the filtering.
Quote collection: Title (text) User (select field relational - reference to firebase users)
Just trying to filter by collection based on the authenticated user. I. E. Load authenticated users quotes.
I've attempted setting up a rule but that doesn't work either
match /fl_content/{content}/{document=**} {
allow read: resource.data.user == request.auth.uid;
}
Thanks for the example. When using the select-relational field to select a user, that user is stored in your Firestore document as a Document Reference. This means that you can't search/filter on it using a string, but you'll have to use a reference.
Your code would look something like this:
const userId = "eVFw95jlMpNmsisGzKJWGHOSguf1"
const userDocRef = firebase.firestore()
.collection('fl_users')
.doc(userId);
const data = await flamelinkApp.content.get({
schemaKey: "quote",
populate: true,
filters: [[ "user", "==", userDocRef ]]
});
Please let me know if that works for you.
Yup that works perfectly thanks!
Thanks for the example. When using the select-relational field to select a user, that user is stored in your Firestore document as a Document Reference. This means that you can't search/filter on it using a string, but you'll have to use a reference.
Your code would look something like this:
const userId = "eVFw95jlMpNmsisGzKJWGHOSguf1" const userDocRef = firebase.firestore() .collection('fl_users') .doc(userId); const data = await flamelinkApp.content.get({ schemaKey: "quote", populate: true, filters: [[ "user", "==", userDocRef ]] });
Please let me know if that works for you.
@jperasmus I tried this with "^1.0.0-alpha.34"
version. Can you please confirm if this has changed by any means? It is not yet working for me. I can still see null values.
Hello
Assuming I have a collection that has a relationship with another field, I'd assume I can filter it as follows
const data = await flamelinkApp.content.get({ schemaKey: "quote", populate: true, filters: [[ "user", "==", "eVFw95jlMpNmsisGzKJWGHOSguf1" ] });
I've tried using["user", "==", "eVFw95jlMpNmsisGzKJWGHOSguf1"] ["user.id", "==", "eVFw95jlMpNmsisGzKJWGHOSguf1"] ["user", "==", "/fl_users/eVFw95jlMpNmsisGzKJWGHOSguf1"] ["user._fl_meta_.docId", "==", "eVFw95jlMpNmsisGzKJWGHOSguf1"]
But nothing works. Help.If i remove the filters then I can see the data.