![Create React App Officially Deprecated Amid React 19 Compatibility Issues](https://cdn.sanity.io/images/cgdhsj6q/production/04fa08cf844d798abc0e1a6391c129363cc7e2ab-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
@google-cloud/datastore
Advanced tools
@google-cloud/datastore is a Node.js client library for Google Cloud Datastore, a NoSQL document database built for automatic scaling, high performance, and ease of application development. It allows you to interact with Google Cloud Datastore to perform operations such as creating, reading, updating, and deleting entities.
Create an Entity
This code sample demonstrates how to create and save a new entity in Google Cloud Datastore. It creates a 'Task' entity with a description and saves it to the datastore.
const { Datastore } = require('@google-cloud/datastore');
const datastore = new Datastore();
const taskKey = datastore.key('Task');
const task = {
key: taskKey,
data: {
description: 'Buy milk'
}
};
datastore.save(task)
.then(() => {
console.log(`Task ${taskKey.id} created successfully.`);
})
.catch(err => {
console.error('ERROR:', err);
});
Retrieve an Entity
This code sample demonstrates how to retrieve an entity from Google Cloud Datastore using its key. It fetches a 'Task' entity by its ID and logs the result.
const { Datastore } = require('@google-cloud/datastore');
const datastore = new Datastore();
const taskKey = datastore.key(['Task', 'taskId']);
datastore.get(taskKey)
.then(([task]) => {
if (!task) {
console.log('No task found.');
return;
}
console.log('Task:', task);
})
.catch(err => {
console.error('ERROR:', err);
});
Update an Entity
This code sample demonstrates how to update an existing entity in Google Cloud Datastore. It updates the description of a 'Task' entity.
const { Datastore } = require('@google-cloud/datastore');
const datastore = new Datastore();
const taskKey = datastore.key(['Task', 'taskId']);
const task = {
key: taskKey,
data: {
description: 'Buy milk and bread'
}
};
datastore.update(task)
.then(() => {
console.log(`Task ${taskKey.id} updated successfully.`);
})
.catch(err => {
console.error('ERROR:', err);
});
Delete an Entity
This code sample demonstrates how to delete an entity from Google Cloud Datastore. It deletes a 'Task' entity by its key.
const { Datastore } = require('@google-cloud/datastore');
const datastore = new Datastore();
const taskKey = datastore.key(['Task', 'taskId']);
datastore.delete(taskKey)
.then(() => {
console.log(`Task ${taskKey.id} deleted successfully.`);
})
.catch(err => {
console.error('ERROR:', err);
});
Mongoose is an ODM (Object Data Modeling) library for MongoDB and Node.js. It provides a schema-based solution to model your application data. While @google-cloud/datastore is used for Google Cloud Datastore, Mongoose is specifically designed for MongoDB, offering a rich set of features for data modeling and validation.
Firebase Admin SDK allows server-side access to Firebase services, including Firestore, which is a NoSQL document database similar to Google Cloud Datastore. While @google-cloud/datastore is specific to Google Cloud's Datastore, Firebase Admin SDK provides access to Firestore, which is part of the Firebase platform, offering real-time data synchronization and offline capabilities.
AWS SDK for JavaScript provides access to Amazon DynamoDB, a fully managed NoSQL database service. Similar to Google Cloud Datastore, DynamoDB is designed for high availability and scalability. The main difference is the cloud provider, with DynamoDB being part of AWS and @google-cloud/datastore being part of Google Cloud.
Cloud Datastore Client Library for Node.js
Read more about the client libraries for Cloud APIs, including the older Google APIs Client Libraries, in Client Libraries Explained.
Table of contents:
npm install @google-cloud/datastore
// Imports the Google Cloud client library
const {Datastore} = require('@google-cloud/datastore');
// Creates a client
const datastore = new Datastore();
async function quickstart() {
// The kind for the new entity
const kind = 'Task';
// The name/ID for the new entity
const name = 'sampletask1';
// The Cloud Datastore key for the new entity
const taskKey = datastore.key([kind, name]);
// Prepares the new entity
const task = {
key: taskKey,
data: {
description: 'Buy milk',
},
};
// Saves the entity
await datastore.save(task);
console.log(`Saved ${task.key.name}: ${task.data.description}`);
}
quickstart();
DEADLINE_EXCEEDED
, java.lang.OutOfMemoryError
Reference Issue: #95
When using the emulator, you may experience errors such as "DEADLINE_EXCEEDED" within your application, corresponding to an error in the emulator: "java.lang.OutOfMemoryError". These errors are unique to the emulator environment and will not persist in production.
A workaround is available, provided by @ohmpatel1997 here.
Samples are in the samples/
directory. The samples' README.md
has instructions for running the samples.
Sample | Source Code | Try it |
---|---|---|
Concepts | source code | ![]() |
Error | source code | ![]() |
Quickstart | source code | ![]() |
Add Task | source code | ![]() |
Delete Task | source code | ![]() |
Legacy Samples | source code | ![]() |
List Tasks | source code | ![]() |
Update Task | source code | ![]() |
The Google Cloud Datastore Node.js Client API Reference documentation also contains samples.
Our client libraries follow the Node.js release schedule. Libraries are compatible with all current active and maintenance versions of Node.js.
Client libraries targetting some end-of-life versions of Node.js are available, and
can be installed via npm dist-tags.
The dist-tags follow the naming convention legacy-(version)
.
Legacy Node.js versions are supported as a best effort:
legacy-8
: install client libraries from this dist-tag for versions
compatible with Node.js 8.This library follows Semantic Versioning.
This library is considered to be General Availability (GA). This means it is stable; the code surface will not change in backwards-incompatible ways unless absolutely necessary (e.g. because of critical security issues) or with an extensive deprecation period. Issues and requests against GA libraries are addressed with the highest priority.
More Information: Google Cloud Platform Launch Stages
Contributions welcome! See the Contributing Guide.
Please note that this README.md
, the samples/README.md
,
and a variety of configuration files in this repository (including .nycrc
and tsconfig.json
)
are generated from a central template. To edit one of these files, make an edit
to its template in this
directory.
Apache Version 2.0
See LICENSE
6.0.0 (2020-05-27)
Datastore.projectId
property has been removed, and replaced with an asynchronous getProjectid()
method. The projectId cannot be determined synchronously, so the previous approach was to use a {{projectId}}
string placeholder if the projectId had not yet been acquired. This made it difficult to know exactly when the property would be defined.FAQs
Cloud Datastore Client Library for Node.js
The npm package @google-cloud/datastore receives a total of 19,209 weekly downloads. As such, @google-cloud/datastore popularity was classified as popular.
We found that @google-cloud/datastore demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.