#Document
DESCRIPTION
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
- '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
-
'social', 'google', {name: 'Chris34'}).getSocial().getGoogle().getName() - string[,string..]
-
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
-
'social', 'facebook').get().social.facebook - string[,string..]
-
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'