0

I'm querying documents to a custom List with firestore. But I want to specify if that document has the current user ID inside, it shouldn't be put in the list.

To clarify: It's a stack of cards. Each card has the option to be skipped. If the user skips it, their id is put in that card's field named "skipped". Therefore, that current user shouldn't see that card again, because the card has a field that says their id has skipped it.

Something like:

List<CustomCard> cards =
        snapshot.documents.where(/* current ID DOESN'T exists in doc["skipped"], so adds to map*/).map((doc) => CustomCard.fromDocument(doc)).toList();

Here's how I'm adding the users Id to the card skipped field:

//On skip button pressed, call:
handleSkip() {
    cardRef.document(projectId).updateData({'skipped.$currentUid': true});
  }

How can I dismiss the card on the stack from being displayed, if that current user id has skipped it?

itslucca
  • 83
  • 2
  • 11

1 Answers1

0

There are no "is not equal" or "does not contain" queries in Cloud Firestore. The two possible workarounds are:

  1. Hide the cards the user has liked in the client.
  2. Keep a list of all the cards the user hasn't liked, and then remove each once the user likes that card.

Given the use-case I'd say #1 seems most feasible.

Also see:

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807