Skip to content

Releases: sebelga/gstore-node

v1.2.0

29 Apr 15:55
Compare
Choose a tag to compare

Updated @google-cloud/datastore dependency to stable 1.0.0 release.

https://github.com/GoogleCloudPlatform/google-cloud-node/releases/tag/datastore-1.0.0

v1.1.0

18 Apr 17:35
Compare
Choose a tag to compare

Added

Custom validation function

With the custom validation function you can now validate embedded entities. See the docs. Thanks @mAiNiNfEcTiOn for this feature!

v1.0.0

29 Mar 17:00
Compare
Choose a tag to compare

⚠️ Breaking change.

All the responses have been refactored to simplify usage with Promises. It is not necessary anymore to read
the first position of the response array to get an entity (const entity = response[0]).
Refer to the documentation of each method for the new responses returned.

Added

showKey option in plain() and queries to return the complete entity Key from the Datastore. It is added as a "__key" property in the entty data.

v0.10.0

21 Feb 17:28
Compare
Choose a tag to compare

Features

Adds support for passing multiple arguments to the validator.js function

You now can pass arguments to the validate in your Schemas to support more validations from validator.js. Thanks @mAiNiNfEcTiOn

Bugs

Fix #37 when passing Array of 1 item to get/delete.

Thanks @micaww

Fix #45 Now deleteAll deletes through batches of 500 entities.

Enhancements

Global save now support transactions (#43)
You can pass the method you need when saving (update, insert or upsert) (#44)

v0.9.1

17 Dec 14:31
Compare
Choose a tag to compare

Fix geoPoint validation bug.

v0.9.0

08 Dec 19:40
Compare
Choose a tag to compare

Added

#22 transform a query back to entities instances

There is a new option setting to return entities instances from queries: gstore.Queries.formats.ENTITY. Instead of plain JSON object (default) you will receive gstore entity instances with all the methods.

query.run({ format: gstore.Queries.formats.ENTITY })
     .then( ... );

#29 Saving multiple entities.

You can now save in batch an Array of entities instances, calling gstore.save([...] ).

const query = BlogModel.query().limit(20);
query.run({ format: gstore.Queries.formats.ENTITY })
      .then((result) => {
        const entities = result[0].entities;

        // entities are gstore instances, you can manipulate them
        // and then save them by calling:

        gstore.save(entities).then(() => {
            ...
        });
      });

#30 Add new validation for GeoPoints

You can now pass a valid object with "longitude" and "latitude" properties for GeoPoints. It will automatically convert to datastore.GeoPoints.

Fix bug

Thanks @raynux. Fixed a bug when trying to retrieve an entity that didn't exist.

v0.8.0

15 Nov 13:33
Compare
Choose a tag to compare

Added

Promise support (yes! :) #11

Happy to announce that gstore now fully support Promises on all async operations. I must give credit to @callmehiphop and @stephenplusplus for their promisify() utility method.
I think it's a big move for the library towards async/await that will come in the future (ES7). For now I recommend the great co package to simulate it.

❗ Breaking change

To support Promises, hooks (middleware) have been completely rewritten. To be able use them you have to use the new Promise implementation and your hooks must now return a Promise. See all the info in the docs.

Virtual properties #23

You can now get and set properties on your entities without the need to do it through entity.get('...') or entity.set('...'). Thanks to virtual properties added on the entity. Thanks @jfbenckhuijsen for this very nice feature.

User.get('123').then((data) => {
    const user = data[0];

    // getter
    // same as doing user.get('email')
    console.log(user.email); // '[email protected]';

    // setter
    // same as doing user.set('email', newvalue), but nicer :)
    entity.email = '[email protected]';

    entity.save().then(() => { ... });
});

Schema "valid values" setting for properties

You can define an Array of valid values for your Schema properties. If you try to save an entity property with a value that is not in the Array it won't validate and not be saved.

var cardSchema = new Schema({
    color: { values: ['red', 'green', 'blue'] }
});

var card = new Card({ color: 'yellow'});
card.save().catch((err) => {
    // will throw an error of validation
});

v0.7.2

05 Nov 14:34
Compare
Choose a tag to compare

Bug fixes. (#21)

v0.7.1

24 Oct 19:03
Compare
Choose a tag to compare

Fix a bug in datastoreEntity() method in entity.js.

v0.7.0

22 Oct 19:34
Compare
Choose a tag to compare

Added compatibility with @google-cloud/[email protected] (#19)

⚠️ Breaking change.
You need to upgrade your dependency to the new @google-cloud/[email protected].

Since this new version of the google datastore the entities data is now on the top level (in previous versions the entities returned were objects with 2 properties {key:entityKey, data:entityData}). There is therefore no more need for a "simplifyResult" parameter in the queries. This affects:

  • Model.query().run()
  • Model.list()
  • Model.findAround()

where "simplifyResult" has been removed. For this reason query().run() does not take anymore an option object as first parameter.

Please report any regression that you might encounter after upgrading.