0.0.32 • Published 9 years ago

eden-document v0.0.32

Weekly downloads
59
License
-
Repository
github
Last release
9 years ago

#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'
0.0.32

9 years ago

0.0.31

9 years ago

0.0.30

9 years ago

0.0.28

10 years ago

0.0.27

10 years ago

0.0.26

10 years ago

0.0.25

10 years ago

0.0.24

10 years ago

0.0.23

10 years ago

0.0.21

10 years ago

0.0.20

10 years ago

0.0.17

10 years ago

0.0.16

10 years ago

0.0.15

10 years ago

0.0.14

10 years ago

0.0.12

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago