JayantSeth
JayantSeth

Reputation: 408

Does gcp firestore in datastore mode support OR query?

Consider following data in GCP datastore:

users: [
{name: 'jane', email: '[email protected]', user_id: 1},
{name: 'jacob', email: '[email protected]', user_id: 2},
{name: 'john', email: '[email protected]', user_id: 3}
]

relations: [
{user1_id: 1, user2_id: 2, relation_name: "spouse"},
{user1_id: 2, user2_id: 3, relation_name: "father_son"}
]

I want to fetch all relations for user jacob for that I need to query for jacob's ID in two columns that is user1_id & user2_id using some sort of OR logic while running datastore query but I am unable to find any document with the required example to make OR query.

Is this possible in one query else I will have to make two separate query one with column user1_id and other user user2_id.

I am using firestore in datastore mode and I am using node js client library to fetch result.

Upvotes: 0

Views: 118

Answers (1)

Manikandan V M
Manikandan V M

Reputation: 26

GCP Firestore in datastore mode does not natively support 'OR' operator but some client libraries add the support for 'OR' operator. Check restriction on queries for more details.

Upvotes: 1

Related Questions