Consider following data in GCP datastore:
users: [
{name: 'jane', email: 'jane@somesite.com', user_id: 1},
{name: 'jacob', email: 'jacob@somesite.com', user_id: 2},
{name: 'john', email: 'john@sometime.com', 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.
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.