Skip to content

Releases: sebelga/gstore-node

v0.6.5

20 Oct 19:43
Compare
Choose a tag to compare

Added

New property on Schema declaration: required (#18)

If it set to true, the entityData value of the property can not be undefined, null or an empty string.

var schema = new Schema({
    name: {type:'string'},
    email: {validate: 'isEmail', required: true}
})
;

var entityData = {name: 'John'}; // won't validate
var entityData = {name: 'John', email: null}; // won't validate
var entityData = {name: 'John', email: ' '}; // won't validate

gstore.defaultValues helper

There is a new constant gstore.defaultValues.NOW that you can use in your Schema declaration as a default value for "datetime" properties. It will automatically return the current time of the request.

var gstore = require('gstore-node');
var Schema = gstore.Schema;

var blogPostSchema = new Schema({
    createdOn : {type:'datetime', default: gstore.defaultValues.NOW},
    ...
});

v0.6.4

18 Oct 19:32
Compare
Choose a tag to compare

Fix

Bug when updating a model data (PR #17 ). Thanks @soraxtend

Added

The possibility to pass a function as a value for a filter in list shortcut query.
This allow for dynamic values to be calculated (for example the current date) as the declaration only occurs once.

// In a Schema definition

var querySettings = {
    filters  : ['publishedOn', '<', function(){ return new Date(); }]
};
blogPostSchema.queries('list', querySettings);

v0.6.3

03 Oct 18:21
Compare
Choose a tag to compare

Added

options object parameter to Model get() method. The options object has a preserveOrder property to be able to maintain the order of the IDs passed (in case of passing an Array of ids) in the results. Thanks @micaww.

Change google-cloud dependency & Fix #16

Fix possible slow loading of the node modules by changing the dependency of gstore from "google-cloud" to only "@google-cloud/datastore"

v0.6.2

26 Aug 15:52
Compare
Choose a tag to compare

Fix #10

Fix a bug where the datastore connection instance from google-cloud was declared on each Model instance.

v0.6.1

14 Aug 07:57
Compare
Choose a tag to compare

Added

When retrieving an Array of ids (Model.get([123, 456]), the resulting entities are now sorted according to the array passed. Thanks @micaww.

Fix

Dependency on the renamed google-cloud (since v0.38.x) library instead of "gcloud"

v0.6.0

02 Aug 10:22
Compare
Choose a tag to compare

Fix #5

Update transaction alias on gstore and internal transaction handling to work with gcloud 0.37
Thank you @micaww for your work on this issue.

v0.5.1

12 Jul 05:37
Compare
Choose a tag to compare

Fix

Issue #2 where String ids with numbers in them were wrongly parsed. Thanks @micaww

v0.5.0

07 Jul 16:16
Compare
Choose a tag to compare

Added

Model.update() has an options parameter that allows to do a replace and save instead of a fetch() -> merge and save()

Fix

Bug with id of type string on entity instances

v0.4.0

28 Jun 19:36
Compare
Choose a tag to compare

Schema

new statics methods
You can now declare static methods for your Models

new method virtual()
Allows you to create virtual properties on schema that are not persisted in the Datastore

Model

new method key()
Creates one or an array of entity Key(s)

Entity

new method model()
Access other models from an entity instance.

new method validate()
Validates en entity data

v0.3.0

22 Jun 16:57
Compare
Choose a tag to compare

Features

Model

  • New method: excludeFromIndexes(Array or String)

Allow to dynamically remove properties from Google Datastore indexes

  • New method sanitize()

With this method you can remove properties from an untrusted source that are not "writable"

  • get()

new parameter : transaction
new parameter : namespace
id can now also be an Array of ids

  • save()

new parameter : transaction

  • udpate()

new parameter : transaction
new parameter : namespace

if schema has a “modifiedOn” property, it will automatically be set to new Date() on save (or update). If for any reason you don’t want this behavior use another property name otherwise it will be overridden.

  • Delete()

new parameter : transaction
new parameter : namespace

  • query()
    new parameter : transaction

Schema

  • New property option read
  • New property option write
  • New property value types:
    • ‘int’ (replaces ‘number’) can be 1 or gcloud.datastore.int(1) gcloud.datastore.int(‘1')
    • ‘double (can be 1, 1.5 or gcloud.datastore.double(‘1’), gcloud.datastore.double(1.3)
    • buffer —> Buffer
    • geoPoint —> gcloud.datastore.geoPoint

Entity

  • new method: datastoreEntity()

Allows to quickly fetch the data of an entity in the Datastore.

Fixes

Model.update() now executes "get() + save()" from inside a transaction

Breaking change

schema type “number” is now “int” and accepts an integer or a "gcloud.datastore.int"