GitXplorerGitXplorer
m

persisetnec

public
1 stars
0 forks
0 issues

Commits

List of commits on branch master.
Unverified
b29d015e2bbafe39ddc8fad367f1f6cce24dee5b

EVEN FEWER FEATURES

jjfhbrook committed 11 years ago
Unverified
02f257165d5c6229fc363e07ab3f2fcf4d8fc1f8

Added a license

jjfhbrook committed 11 years ago
Unverified
e53848f039ec88d18695880aa85736a6fd5457f2

An ODM on level in <40 lines? Daaaaang

jjfhbrook committed 11 years ago
Unverified
66ab22d1e25bddfac52a9a411ef172d76354cbc7

[api] First import of persistence library

jjfhbrook committed 11 years ago

README

The README file for this repository.

persisetnec

A odm for leveldb

install:

$ npm install persisetnec

use:

var persisetnec = require('persisetnec');

// Get us a persistence layer
var persist = persisetnec('./some-level-db-path');

// Define *some* model or other
// NOTE: The call signature MUST be an options hash!
// (this is used for restoring)
var Pony = function(opts) {
  opts = opts || {};
  this.color = opts.color || 'white';
};

Pony.prototype.neigh = function() { return 'neiiiiigh!!'; };

// Register our model with persisetnec
persist.add('Pony', Pony);

// Now you can put Ponies into your db...
var hidalgo = new Pony({ color: 'black' });
Pony.put('hidalgo', hidalgo, function(err) {
  if (err) throw err;

  // You can get Ponies too...
  Pony.get('hidalgo', function(err, hidalgo) {
    if (err) throw err;
    console.log(hidalgo.color); // black
  });
});

lack of features:

  • Schemas. Don't need schemas to persist, implement in another layer.
  • Relationships. These may come later, or be implemented in a separate package.
  • Documentation. The source code is ~40 lines right now so you can probably just read it. For now.
  • Simple name. Yeah, this is a spin on an already obscure inside joke.

license:

MIT