GithubHelp home page GithubHelp logo

osmos's Introduction

Osmos: a strict, store-agnostic object data mapper for Node.js


IMPORTANT: This documentation refers to version 1.x of Osmos, which introduces a large number of differences from the 0.x branch, many of which break compatibility.

If you wish to continue using the 0.x branch, you can check out the documentation here.


Osmos is a object data mapper (ODM) designed to bridge Node.js apps with any data store that support traditional CRUD operations. It's built on three principles:

  • Stay out of the way. Osmos is intuitive and largely transparent to developers, and, most of all, doesn't attempt to be “smarter” than its human masters. It can also be easily mocked away for testing without having to write specialized code.

  • Fail early, and fail loudly. Osmos uses Harmony Proxies to trap access to a document; if attempts are made to read or write non-existent fields, an error is immediately thrown to help you and pinpoint common mistakes before they end up in production.

  • Don't replace developer knowledge. Osmos is designed to be a generic ODM that will work well with just about any data store that supports CRUD operations. However, it is not meant to be an abstraction layer; instead, it assumes that developers know best, and provides only a simple interface that can be easily extended through plugins.

The current version of Osmos supports RethinkDB, with a MongoDB driver in the works, but it should be easy to write drivers for just about any data store—and contributions are warmly welcome! The library also includes a simple, memory-based data store that can be used for testing purposes.

Installation

npm install osmos-odm

Note that Osmos uses Harmony Proxies in order to work. Therefore, you must run your instance of node with the --harmony_proxies command-line switch.

Usage

Using Osmos requires the following steps:

  1. Create a driver instance. A driver instance connects Osmos to a data store. Learn more about drivers.

  2. Install and invoke zero or more plugins. Plugins allow you to extend the functionality provided by Osmos. They are, of course, optional. Learn more about plugins

  3. Define your schemas. A schema describes the structure of a document, and defines how its data is transformed and validated. Learn more about schemas

  4. Define your models. A model applies a schema to data that is extracted from a data store's specific bucket. Learn more about models

  5. CRUD. Models can be used to create, read, update and delete existing document. Two find methods are also supplied. Learn more about documents.

  6. Additional functionality can be also added to Osmos by a plugin or by a driver—for example, to provide access to features of a data store that are not part of the basic CRUD quartet.

Contributing

Contributions in the form of patches and pull requests are welcome, provided that you also commit to writing covering unit tests. Learn more about contributing.

Roadmap

Version 1.x of the project aims at greatly simplifying its structure by using standard validation based on JSON Schema and applying many of the lessons learned through its use in production. However, it introduces a significant number of backwards-breaking compatibilities; version 0.x is still available in the corresponding branch.

Osmos is still a fairly new project, and bug fixing is the priority, as well as the addition of support for more drivers.

osmos's People

Contributors

mtabini avatar skateordie avatar

Watchers

Navid Nikpour avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.