Socket
Socket
Sign inDemoInstall

eden-document

Package Overview
Dependencies
8
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    eden-document

Eden Node JS Generic Document Definition


Version published
Weekly downloads
2
increased by100%
Maintainers
1
Install size
399 kB
Created
Weekly downloads
 

Readme

Source

#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

FAQs

Last updated on 01 Jun 2015

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc