Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

xylem

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

xylem

Cross database object persistence for Node.js.

  • 0.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4
increased by300%
Maintainers
1
Weekly downloads
 
Created
Source

Xylem

Xylem provides a mechanism to persist and manipulate data on the file system, memory or a database server.

Differently from other ORM/ODM tools out there, Xylem allows you to reference and combine data from different sources, making it the ultimate storage abstraction library to back a REST server, a CMS or any other data driven application.

Getting started

Installing Xylem

$ npm install xylem

Installing an adapter

$ npm install xylem-mongodb

Creating connections

var Server = require('xylem');
var MongoDB = require('xylem-mongodb');

var server = new Server();

server
  .adapter('mongodb', MongoDB)
  .connection('database', 'mongodb://localhost/xylem');

Creating models

server.model('contact', {
  connection: 'database',
  fields: {
    id: 'string',
    name: 'string',
    email: 'string'
  },
  key: 'id'
});

Storing and retrieving data

var Contact = server.model('contact');

var john = new Contact({
  id: 1,
  name: 'John',
  email: 'john@example.com'
});

john.save(function (error, john) {
  console.log(john);

  // Get a list of contacts.
  Contact.list({}, function (error, contacts) {
    console.log(contacts);
  });
});

Adapters

Xylem adapters are the bridge between Xylem and the underlying storage system.

  • Memory (Built in)
  • MongoDB

Lifecycle callbacks

Save operation

  • beforeSave(settings, item, callback)
  • afterSave(settings, item, callback)

List operation

  • beforeList(settings, query, callback)
  • afterList(settings, items, callback)

Get operation

  • beforeGet(settings, key, callback)
  • afterGet(settings, item, callback)

Destroy operation

  • beforeDestroy(settings, key, callback)
  • afterDestroy(settings, item, callback)

Features

  • Pluggable adapters
  • Multiple storages
  • Object relationship
  • Polymorphic objects (subtyping)
  • Embedded objects
  • Query builder

Keywords

FAQs

Package last updated on 27 Feb 2015

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc