Coder Social home page Coder Social logo

ogm's Introduction

OrientJS OGM for Node.JS

Build Status npm version Stories in Ready

Simple Object Graph Mapper based on ES6 classes and using ES7 decorators.

Installation

Install via npm.

npm install ogm

Running Tests

To run the test suite, first invoke the following command within the repo, installing the development dependencies:

npm install

Then run the tests:

npm test

Features

  • Using official OrientDB driver for node.js orientjs.
  • Intuitive API, based on next gen javascript.

Usage

Configuring the client.

import * as ogm from 'ogm';

var server = ogm.connect({
  host: 'localhost',
  port: 2424,
  username: 'root',
  password: 'yourpassword'
});

Using an existing database

var db = ogm.use('mydb');
console.log('Using database: ' + db.name);

Using an existing database with credentials

var db = ogm.use({
  name: 'mydb',
  username: 'admin',
  password: 'admin'
});
console.log('Using database: ' + db.name);

Defining simple model

@ogm.model("Person")
class Person extends ogm.V {

  @ogm.property(String)
  name = this.name;

  @ogm.property(Number)
  age = this.age;
}

Create, Edit, Save and Delete from model

var john = new Person({name: 'John'});

// Saving new instance
await john.save();

// Editing properties
john.age = 12;

//Saving changes
await john.save();

//Deleting instance
await john.delete();

Query model

var john = await Person.query({name: 'John'}).one();

// Getting by rid
var john = await Person.get('#1:1');

ogm's People

Contributors

eafzali avatar

Watchers

James Cloos 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.