Mixin: pkey

pkey

This mixin provides pkey() and overrides read() and write() method to install a primary key feature. This mixin must be loaded after storage mixin or other storage-type mixins.
Source:

Example

var opts = {
  storage: 'memory',
  primary_key: 'name'
};
var collection = new KagoDB(opts);

var john = {
  name: 'Jonathan',
  nickname: 'john'
};
collection.save(john);
collection.write('Jonathan', john); // does same as above

var mike = {
  nickname: 'mike'
};
collection.write('Michael', mike); // name: 'Michael' will be added