Coder Social home page Coder Social logo

rw3iss / objectdatamapper Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 14 KB

This is a simple module which expects a defined object schema (currently based on db-migrate library), and presents CRUD methods for any arbitrary object to a database based on those schemas (currently only supporting mysql).

JavaScript 100.00%

objectdatamapper's Introduction

ObjectDataMapper

This is a simple module which expects a defined object schema, and presents CRUD methods for any arbitrary object to a database (currently only supporting mysql). It's designed to be as simple as possible so as to provide the most transparency between high level and low level operations.

Note that the current schema definitions conform to the schemas used in db-migrate library (can be changed if necessary): https://db-migrate.readthedocs.io/en/latest/API/SQL/ (This is just for ease at the moment and I'd like to change it soon enough)

What This Does

Essentially this module takes a predefined json schema for your database, and exposes methods to work with the data. For example, when using the save() method, the schema is looked up from the passed in type argument. Then, a query is generated using all the properties that exist on the passed in type's object schema. Then the object is committed to the database.

Example Usage

ObjectDataMapper.save('sometype', object);
ObjectDataMapper.find('sometype', properties);

Methods

save(type, object) - performs an insert or an update, returning a promise. Promise will return an ID if it's a new object.
find(type, properties) - performs a search, filtering by the given properties, returning a promise.

What It Doesn't Do

Any kind of sophisticated joins or other-than-basic functionality for simple one-dimensional CRUD operations, for now. I will probably incorporate joining based on preferences set in the schema (ie. lazy-loading vs. on-the-fly for model properties that are foreign references).

Dependencies

mysql

objectdatamapper's People

Contributors

rw3iss avatar

Watchers

 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.