New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More →

@google-cloud/datastore

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@google-cloud/datastore - npm Package Compare versions

Comparing version

to
0.6.0

{
"name": "@google-cloud/datastore",
"version": "0.5.1",
"version": "0.6.0",
"author": "Google Inc.",

@@ -53,3 +53,3 @@ "description": "Google Cloud Datastore Client Library for Node.js",

"dependencies": {
"@google-cloud/common": "^0.8.0",
"@google-cloud/common": "^0.9.0",
"arrify": "^1.0.0",

@@ -56,0 +56,0 @@ "concat-stream": "^1.5.0",

@@ -1,2 +0,2 @@

# @google-cloud/datastore
# @google-cloud/datastore ([Beta][versioning])
> Google Cloud Datastore Client Library for Node.js

@@ -72,14 +72,8 @@

### On Google Compute Engine
### On Google Cloud Platform
If you are running this client on Google Compute Engine, we handle authentication for you with no configuration. You just need to make sure that when you [set up the GCE instance][gce-how-to], you add the correct scopes for the APIs you want to access.
If you are running this client on Google Cloud Platform, we handle authentication for you with no configuration. You just need to make sure that when you [set up the GCE instance][gce-how-to], you add the correct scopes for the APIs you want to access.
``` js
// Authenticating on a global basis.
var projectId = process.env.GCLOUD_PROJECT; // E.g. 'grape-spaceship-123'
var datastore = require('@google-cloud/datastore')({
projectId: projectId
});
var datastore = require('@google-cloud/datastore')();
// ...you're good to go!

@@ -90,3 +84,3 @@ ```

If you are not running this client on Google Compute Engine, you need a Google Developers service account. To create a service account:
If you are not running this client on Google Cloud Platform, you need a Google Developers service account. To create a service account:

@@ -118,2 +112,3 @@ 1. Visit the [Google Developers Console][dev-console].

[versioning]: https://github.com/GoogleCloudPlatform/google-cloud-node#versioning
[google-cloud]: https://github.com/GoogleCloudPlatform/google-cloud-node

@@ -120,0 +115,0 @@ [gce-how-to]: https://cloud.google.com/compute/docs/authentication#using

@@ -284,6 +284,3 @@ /*!

*
* transaction.save({
* key: key,
* data: entity
* });
* transaction.save(entity);
*

@@ -290,0 +287,0 @@ * transaction.commit(function(err) {

@@ -71,2 +71,38 @@ /*!

/**
* Format a user's input to mutation methods. This will create a deep clone of
* the input, as well as allow users to pass an object in the format of an
* entity.
*
* Both of the following formats can be supplied supported:
*
* datastore.save({
* key: datastore.key('Kind'),
* data: { foo: 'bar' }
* }, function(err) {})
*
* var entity = { foo: 'bar' }
* entity[datastore.KEY] = datastore.key('Kind')
* datastore.save(entity, function(err) {})
*
* @private
*
* @resource [#1803]{@link https://github.com/GoogleCloudPlatform/google-cloud-node/issues/1803}
*
* @param {object} obj - The user's input object.
*/
DatastoreRequest.prepareEntityObject_ = function(obj) {
var entityObject = extend(true, {}, obj);
// Entity objects are also supported.
if (obj[entity.KEY_SYMBOL]) {
return {
key: obj[entity.KEY_SYMBOL],
data: entityObject
};
}
return entityObject;
};
/**
* Generate IDs without creating entities.

@@ -430,3 +466,6 @@ *

DatastoreRequest.prototype.insert = function(entities, callback) {
entities = arrify(entities).map(propAssign('method', 'insert'));
entities = arrify(entities)
.map(DatastoreRequest.prepareEntityObject_)
.map(propAssign('method', 'insert'));
this.save(entities, callback);

@@ -868,49 +907,49 @@ };

// then place in the correct mutation array (insert, update, etc).
entities.forEach(function(entityObject, index) {
entityObject = extend(true, {}, entityObject);
entities
.map(DatastoreRequest.prepareEntityObject_)
.forEach(function(entityObject, index) {
var mutation = {};
var entityProto = {};
var method = 'upsert';
var mutation = {};
var entityProto = {};
var method = 'upsert';
if (entityObject.method) {
if (methods[entityObject.method]) {
method = entityObject.method;
} else {
throw new Error('Method ' + entityObject.method + ' not recognized.');
}
}
if (entityObject.method) {
if (methods[entityObject.method]) {
method = entityObject.method;
} else {
throw new Error('Method ' + entityObject.method + ' not recognized.');
if (!entity.isKeyComplete(entityObject.key)) {
insertIndexes[index] = true;
}
}
if (!entity.isKeyComplete(entityObject.key)) {
insertIndexes[index] = true;
}
if (is.array(entityObject.data)) {
entityProto.properties = entityObject.data.reduce(function(acc, data) {
var value = entity.encodeValue(data.value);
if (is.array(entityObject.data)) {
entityProto.properties = entityObject.data.reduce(function(acc, data) {
var value = entity.encodeValue(data.value);
if (is.boolean(data.excludeFromIndexes)) {
var excluded = data.excludeFromIndexes;
var values = value.arrayValue && value.arrayValue.values;
if (is.boolean(data.excludeFromIndexes)) {
var excluded = data.excludeFromIndexes;
var values = value.arrayValue && value.arrayValue.values;
if (values) {
values = values.map(propAssign('excludeFromIndexes', excluded));
} else {
value.excludeFromIndexes = data.excludeFromIndexes;
if (values) {
values = values.map(propAssign('excludeFromIndexes', excluded));
} else {
value.excludeFromIndexes = data.excludeFromIndexes;
}
}
}
acc[data.name] = value;
acc[data.name] = value;
return acc;
}, {});
} else {
entityProto = entity.entityToEntityProto(entityObject.data);
}
return acc;
}, {});
} else {
entityProto = entity.entityToEntityProto(entityObject.data);
}
entityProto.key = entity.keyToKeyProto(entityObject.key);
entityProto.key = entity.keyToKeyProto(entityObject.key);
mutation[method] = entityProto;
mutations.push(mutation);
});
mutation[method] = entityProto;
mutations.push(mutation);
});

@@ -959,3 +998,6 @@ var protoOpts = {

DatastoreRequest.prototype.update = function(entities, callback) {
entities = arrify(entities).map(propAssign('method', 'update'));
entities = arrify(entities)
.map(DatastoreRequest.prepareEntityObject_)
.map(propAssign('method', 'update'));
this.save(entities, callback);

@@ -968,3 +1010,6 @@ };

DatastoreRequest.prototype.upsert = function(entities, callback) {
entities = arrify(entities).map(propAssign('method', 'upsert'));
entities = arrify(entities)
.map(DatastoreRequest.prepareEntityObject_)
.map(propAssign('method', 'upsert'));
this.save(entities, callback);

@@ -971,0 +1016,0 @@ };

Sorry, the diff of this file is not supported yet