nodejs-datastore
nodejs-datastore copied to clipboard
Query Select Method is causing empty results
I'm having an issue where when I use the select method on a query I get no results. I have a simple datastore holding user profile data under the Profile kind. The structure of an entity of that kind is as follows.
{
id: string;
name: string;
email: string;
picture: string;
roles: string[];
boards: string[];
defaultBoard: string;
}
When I run a query getting all the users with a name falling in a specific character range I get the results that I expect and select only the fields I need I get no results.
const query = datastore
.createQuery("Profile")
.filter("name", ">=", "Da")
.filter("name", "<=", "Daz")
.select(["name", "email", "id", "picture"]);
const [entities] = await retry(() => query.run());
If I comment out the select it will work fine. I have the proper index built and have even tried to rebuild it but that did not help.
- kind: Profile
properties:
- name: name
- name: email
- name: id
- name: picture
Do you have any idea if I'm doing something wrong? I have used select in the past successfully but it appears not to be working now.
Thanks
Environment details
- OS: Windows 10
- Node.js version: v14.15.4
- npm version: 6.14.10
@google-cloud/datastoreversion: ^6.3.1
Thanks!
Any follow up on this?
I hit the same issue yesterday.
What is that retry function? Could you provide an import please?
Can you try this?
// Imports the Google Cloud client library
const {Datastore} = require('@google-cloud/datastore');
// Creates a client
const datastore = new Datastore();
async function getResults() {
const query = datastore
.createQuery("Profile")
.filter("name", ">=", "Da")
.filter("name", "<=", "Daz")
.select(["name", "email", "id", "picture"]);
const [entities] = await query.run();
console.log(entities);
}
getResults();
Can't reproduce. Please open if you need more help.