Releases: sebelga/gstore-node
v0.6.5
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
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
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
v0.6.1
v0.6.0
v0.5.1
v0.5.0
v0.4.0
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
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"