npm.io
0.0.32 • Published 11 years ago

eden-document

Licence
Version
0.0.32
Deps
2
Vulns
0
Weekly
0
DeprecatedThis package is deprecated

#Document

DESCRIPTION

Build Status

General

Installation

npm install eden-document
Usage
var document = require('eden-document');

Methods


path
 mixed path('social', 'facebook', 'name');

Returns a value in document given the key path

Parameters
  1. 'social', 'facebook', 'name' - string[,string..]
Returns

mixed

Example
Code
var user = document({ name: 'chris', social: { facebook: { name: 'Chris12' }, twitter: { name: 'Chris23' } } });
user.path('social', 'facebook', 'name');
user.path('social', 'twitter').getName());
user.path('social', 'twitter').get().name);
Outputs
'Chris12'
'Chris23'
'Chris23'

set
 this set('social', 'google', {name: 'Chris34'}).getSocial().getGoogle().getName());

Sets a value in document given the key path where the last argument is the value to set

Parameters
  1. 'social', 'google', {name: 'Chris34'}).getSocial().getGoogle().getName() - string[,string..]

  2. mixed

Returns

this

Example
Code
var user = document({ name: 'chris', social: { facebook: { name: 'Chris12' }, twitter: { name: 'Chris23' } } });

user.set('social', 'google', {name: 'Chris34'}).getSocial().getGoogle().getName());
user.set('social', 'google', 'name', 'foo', 'bar').get().social.google.name.foo);
Outputs
'Chris34'
'bar'

unset
 this unset('social', 'facebook').get().social.facebook);

Removes a value in model given the key path

Parameters
  1. 'social', 'facebook').get().social.facebook - string[,string..]

  2. mixed

Returns

this

Example
Code
var user = document({ name: 'chris', social: { facebook: { name: 'Chris12' }, twitter: { name: 'Chris23' } } });

typeof user.unset('social', 'facebook').getSocial().getFacebook());
typeof user.unset('social', 'facebook').get().social.Facebook);
typeof user.unset('social', 'twitter', 'name').getSocial().getTwitter().name);
Outputs
'undefined'
'undefined'
'undefined'

Keywords