We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
firebase-tools: v13.6.0
Platform: macOS Sonoma 14.4
node: v20.10.0
gcloud: v470.0.0
cloud-firestore-emulator: v1.19.4
MCVE - https://github.com/aalej/issues-6932
Alternatively, make a directory containing the ff files:
import { Datastore } from "@google-cloud/datastore"; const datastore = new Datastore({ projectId: "some-testproject", }); export async function getNamespaces() { const query = datastore.createQuery("__namespace__").select("__key__"); const [entities] = await datastore.runQuery(query); const namespaces = entities.map((entity) => entity[datastore.KEY].name); return namespaces; } export async function addEntity(namespace: string, kind: string[], data: any) { const entityKey = datastore.key({ path: kind, namespace, }); const entity = { key: entityKey, data, }; await datastore.save(entity); } async function main() { await addEntity("Tasks", ["Work Tasks"], { category: "Personal", done: false, priority: 4, description: "Learn Cloud Datastore", }); const namespaces = await getNamespaces(); console.log(namespaces); } main();
{ "compilerOptions": { "target": "es2016", "module": "commonjs", "esModuleInterop": true, "forceConsistentCasingInFileNames": true, "strict": true, "skipLibCheck": true, "outDir": "lib" }, "include": ["src"], "exclude": [] }
{ "version": "1.0.0", "description": "", "main": "lib/index.js", "scripts": { "build": "tsc", "build:watch": "tsc --watch" }, "devDependencies": { "@google-cloud/datastore": "^8.6.0", "typescript": "^5.4.3" } }
Testing while connected to the emulator
npm i
gcloud emulators firestore start --database-mode=datastore-mode --host-port=127.0.0.1:8081
export DATASTORE_EMULATOR_HOST=127.0.0.1:8081
npm run build
node .
node lib/index.js
Console logs should show the namespaces on Datastore emulator.
When connecting to production, console logs show the namespaces on Datastore:
[ 'Tasks' ]
Steps to test on a production environment:
unset DATASTORE_EMULATOR_HOST
export GOOGLE_APPLICATION_CREDENTIALS=<path_to_service_account_key.json>
When connected to the emulator, console log outputs an empty array
[]
The text was updated successfully, but these errors were encountered:
harshyyy21
No branches or pull requests
[REQUIRED] Environment info
firebase-tools: v13.6.0
Platform: macOS Sonoma 14.4
node: v20.10.0
gcloud: v470.0.0
cloud-firestore-emulator: v1.19.4
[REQUIRED] Test case
MCVE - https://github.com/aalej/issues-6932
Alternatively, make a directory containing the ff files:
src/index.ts
tsconfig.json
package.json
[REQUIRED] Steps to reproduce
Testing while connected to the emulator
npm i
gcloud emulators firestore start --database-mode=datastore-mode --host-port=127.0.0.1:8081
export DATASTORE_EMULATOR_HOST=127.0.0.1:8081
npm run build
node .
ornode lib/index.js
[REQUIRED] Expected behavior
Console logs should show the namespaces on Datastore emulator.
When connecting to production, console logs show the namespaces on Datastore:
Steps to test on a production environment:
unset DATASTORE_EMULATOR_HOST
export GOOGLE_APPLICATION_CREDENTIALS=<path_to_service_account_key.json>
npm run build
node .
ornode lib/index.js
[REQUIRED] Actual behavior
When connected to the emulator, console log outputs an empty array
The text was updated successfully, but these errors were encountered: