Gstore Node Versions Save

Google Datastore Entities Modeling for Node.js

v9.0.0

2 months ago

⚠ BREAKING CHANGES

  • YES
  • Entity keys return ids as Number

Features

Bug Fixes

  • src/serializers/datastore.ts: load cached entities with correct Datastore Key type (#265) (b06641b), closes #243

v8.0.0

2 months ago

⚠ BREAKING CHANGES

  • datastore.ts: Entity keys return ids as Number

⚠ KNOWN ISSUES

  • Caching - when not using in memory caching (e.g. Redis cache) Date objects data is not being correctly deserialized to Date objects

    • Workaround - cast known Date data to a Date object using the new Date() JavaScript constructor

Bug Fixes

  • datastore.ts: ensure entities with id based keys are correcly loaded from cache (a3a5b33), closes #243

v7.2.8

2 years ago

Bug Fixes

  • fix(src/serializers/datastore.ts): load cached entities with correct Datastore Key type (#265) b06641b
  • fix incorrectly published new package

v7.2.7

2 years ago

Bug Fixes

  • fix(src/serializers/datastore.ts): load cached entities with correct Datastore Key type (#265) b06641b
  • test(integration tests): add integration tests for fineOne and check entityKey construction (#246) b87a275

Dependency upgrades

  • chore(deps): bump validator from 13.0.0 to 13.7.0 (#257) d35f66a
  • chore(deps): bump tmpl from 1.0.4 to 1.0.5 (#256) fef76a2
  • chore(deps): bump path-parse from 1.0.6 to 1.0.7 (#255) 707943e
  • chore(deps): bump glob-parent from 5.0.0 to 5.1.2 (#253) 8782798
  • chore(deps): bump hosted-git-info from 2.7.1 to 2.8.9 (#251) 4012b03
  • chore(deps): bump handlebars from 4.7.6 to 4.7.7 (#250) b75752e
  • chore(deps): bump redis from 3.0.2 to 3.1.2 (#249) 3cb6c45
  • chore(deps): bump y18n from 4.0.0 to 4.0.1 (#248) 766310d
  • chore(deps): bump elliptic from 6.5.3 to 6.5.4 (#247) 5d083f7

Documentation

  • docs(github issue templates): add github issue templates (#245) 605a848

https://github.com/sebelga/gstore-node/compare/v7.2.6...v7.2.7

v7.2.6

3 years ago

v7.2.0

4 years ago

Features

  • Typescript: Improve typings support (43d9dc2)

The code base has been converted to Typescript, as a result the typings have been improved.

const gstore = new Gstore();
const { Schema } = gstore;

interface User {
    name: string;
    age: number;
}

// Schema
const userSchema = new Schema<User>({
    email: { type: String },
    age: { type: Number }
}); 

// Model
const User = gstore.model('User', userSchema); // No need to provide the types here

// Entity
const user = new User({ name: 'John' }); // TS error as "age" is not provided

// Queries
const query = User.query();
query.filter('age', '<', 'wrong string'); // TS error as "age" should be a number
query.filter('wrongProperty',  'some value'); // TS error as "wrongProperty" does not exist in User

// We can also specify the format of the response ("JSON" is the default and thus optional)
const query = User.query<'ENTITY'>(); // Provide the response ("ENTITY")

query.run({ format: 'ENTITY' }).then(result => {
    const { entities } = result;
    const [user] = entities;
    
    // "user" is an Entity instance with its methods
    user.save();
});

// Shortcut queries (`list()` and `findAround()`) response are automatically typed from the `format` option
User.list({ format: 'ENTITY' }).populate().then((result) => {
    const { entities } = result;
    const [user] = entities;
    const age = user.age; // number
    user.save(); // method from the entity instance
});

v7.0.0

4 years ago

⚠ BREAKING CHANGES

  • entitykey: The "keyType" Schema option has been removed as it is no longer needed. Also, as gstore does not parse the id anymore, running your project against the Datastore emulator locally might break as the emulator treats differently User.get(123) than User.get("123"). Auto-allocated ids are integers and need to be provided as integers for the Emulator.

  • Dependencies: Node version 8.x not supported anymore. Upgrade to v10.x or superior.

  • Dependencies: The @google-cloud/datastore package is not defined anymore as a dependency of gstore-node. You will need to manually install it in your project.

  • Dependencies: Set google-cloud datastore as peerDependency (#177) (ac52ffb)

  • Dependencies: Update lib dependencies (#178) (7fa94b1)

Bug Fixes

  • call execPostHooks on internalTransaction (#161) (7b132cf)
  • entity: add "id" property to entity after it has been saved (#180) (15a713a), closes #172
  • entitykey: remove convertion of string number to integer for entity key id (#179) (75dc869), closes #168
  • excludefromindexes: update logic to add all properties of Array embedded entities (#182) (c9da35b), closes #132
  • model: throw NOT_FOUND error when trying to update a Model that does not exist (#181) (cc11e02), closes #164
  • Types: Schema methods() signature (#171) (4a144ce)

v6.0.0

5 years ago

This release mainly addresses a bug on the Model.get() method.

BREAKING CHANGE

When an Array of ids is provided to Model.get(), gstore will now consistently return an Array. In earlier versions, if an array of one id was provided, gstore would return a single entity instead of an array containing the entity.

v5.0.0

5 years ago

Features

Bug Fixes

  • Model.update(): Fix bug in Model.update() inside a transaction (#148) (e4cfaa6), closes #144

BREAKING CHANGES

  • Change gstore instantiation to be consistent with es modules (#149) (3f27d4c)
// The old way
const gstore = require('gstore-node')();

// the new way
const { Gstore, instances } = require('gstore-node');
const gstore = new Gstore(/*optional*/ config);

// You can then save that instance...
instances.set('default', gstore); // "default" is a unique id for that instance

// ... and retrieve it anywhere in your app
const { instances } = require('gstore-node');
const gstore = instances.get('default'); 
  • Callbacks (hell) are not supported anymore as the last argument of any of the gstore methods. Only Promises are returned.
  • Node runtime must be version 8 or superior
  • The old Schema property types "datetime" and "int" have been removed. Date and Number types should be used instead.

v4.3.0

5 years ago

Features

New global config: errorOnEntityNotFound

You can now define if gstore should throw an error when an entity is not found. If you prefer to simply return null when an entity is not found, pass errorOnEntityNotFound: false when creating the gstore instance

const Gstore = require('gstore-node');
const gstore = Gstore({ errorOnEntityNotFound: false });

...

MyModel.get('id-that-does-not-exist').then((entity) => {
    console.log(entity); // null
});

New entity property config: excludeFromRead

You can now specify in your schema properties you don't want to output from you embedded entities by specifying an array of properties to exclude when calling entity.plain()

schema = new Schema({
    embedded: { type: Object, excludeFromRead: ['prop1', 'prop2'] },
});

...

const entity = new MyModel({
    embedded: { prop1: '1', prop2: '2', prop3: '3' }
});

const output = entity.plain();
console.log(output); // { embedded: { prop3: '3' } }

You can also remove nested properties with a "." notation

schema = new Schema({
    embedded: { type: Object, excludeFromRead: ['prop1.nested'] },
});

...

const entity = new MyModel({
    embedded: {
        prop1: { something: 'abc', nested: 'def' },
        prop2: '2'
    }
});

const output = entity.plain();
console.log(output); // { embedded: { prop1: { something: 'abc' }, prop2: '2' } }

Many thanks to @huysamen for both these new features!