nodejs-datastore icon indicating copy to clipboard operation
nodejs-datastore copied to clipboard

Please support != (not equal), IN, NOT IN filters

Open Leejjon opened this issue 3 years ago • 0 comments

Please implement the "special query types" that are supported in the Java & Python clients but not in Node.js as described here: https://cloud.google.com/datastore/docs/concepts/queries#special_query_types

I used to have a Java backend on Google App Engine. Since my frontend was React.js with TypeScript, I switched to a Node.js TypeScript backend (to be able to have shared request and response objects on the frontend and backend). I recently have more of a need to query with an IN filter and noticed that I can't use this.

I have a script that stores football matches from over 10+ competitions in my datastore. My "getUpcoming10Matches" query needs to display the 10 upcoming matches from the competitions that a user selects. OR clauses are not possible as far as I know.

let query = datastore.createQuery('match')
     .order('startTimestamp', {descending: false})
     .filter('startTimestamp', '>', currentTimestamp.toJSON())
     .filter('competitionId', "2003")
     /* OR */
     .filter('competitionId', "2021")
     .limit(10);

I would like to do something like:

let query = datastore.createQuery('match')
    .order('startTimestamp', {descending: false})
    .filter('startTimestamp', '>', currentTimestamp.toJSON())
    .filter('competitionId', 'IN',  ["2003", "2021"])
    .limit(10);

My alternatives currently are: 1 Do two or more queries and merge the results from both and take the first 10 based on the start timestamp 2 Creating a Java or Python web service only for the specific query with the IN filter I need 3 Migrating my datastore to a native firestore (requires creating a new app engine project and migrating everything)

I'm probably going for option 1 until this is resolved.

Leejjon avatar Aug 03 '22 06:08 Leejjon