Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
A mixin to be inherited by objects that manager entities.
JavaScript

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
test
.gitignore
README.md
index.js
package.json

README.md

piton-entity - Common functions to work with data entities

Tools for managing objects that represent business entities

Installation

$ npm install piton-entity

Usage

var EntityDefinition = require('piton-entity');

var entityDefinition = EntityDefinition.createEntityDefinition({
    name: {
        tag: ['update'],
        name: 'Full Name'
    },
    age: {
        type: 'number',
        defaultValue: 0
    },
    active: {
        type: 'boolean',
        defaultValue: true
    },
    phoneNumber: {
        tag: ['update']
    }
});

var blank = entityDefinition.makeBlank();
// blank is now equal to:
//  {
//      name: null,
//      age: null,
//      active: null,
//      phoneNumber: null
//  }

var default = entityDefinition.makeDefault();
// default is now equal to:
//  {
//      name: null,
//      age: 0,
//      active: true,
//      phoneNumber: null
//  }

var stripped = entityDefinition.stripUnknownProperties({
    name: 'Dom',
    extra: 'This should not be here'
});
// stripped is now equal to:
//  {
//      name: 'Dom'
//  }

Credits

Paul Serby Dom Harrington

Licence

Licenced under the New BSD License

Something went wrong with that request. Please try again.