1.0.33 • Published 7 years ago

turtle-orm v1.0.33

Weekly downloads
6
License
MIT
Repository
github
Last release
7 years ago

Turle ORM

Turtle ORM aims to allow developers to use several relational and non-relational databases as a persistent layer abstracction for their nodejs projects, with a simple and agnostic logic. It uses well known libraries to handle database interaction.

At this time turltle supports the following databases:

  • MongoDB (moongose)
  • MySQL (sequelize)

Get Started

installation

npm i turtle-orm --save

MongoDB Example

const Database = require('turtle-orm').Database;
const ModelFactory = require('turtle-orm').ModelFactory;
const Types = require('turtle-orm').Types;

let Users = ModelFactory.model('users', {
    username: { type: Types.STRING },
    password: { type: Types.STRING },
    clientId: { type: Types.OBJECT_ID }
});

let database = Database.create({
    dialect: 'mongodb',
    port: 27017,
    hostName: 'localhost',
    databaseName: 'test',
    username: 'db_username',
    password: 'myPas$w0rd'
});

database.connectAndSync().then(() => {
    let userInstance = Users.create({ username: 'test@gmail.com', password: 'pass' });

    userInstance.save().then(resource => {
        console.log("I'm a mongo document", resource);
    });
});

MySQL Example

const Database = require('turtle-orm').Database;
const ModelFactory = require('turtle-orm').ModelFactory;
const Types = require('turtle-orm').Types;

let Users = ModelFactory.model('users', {
    username: { type: Types.STRING },
    password: { type: Types.STRING }
});

let database = Database.create({
    dialect: 'mysql',
    port: 3306,
    hostName: 'localhost',
    databaseName: 'test',
    username: 'db_username',
    password: 'myPas$w0rd'
});

database.connectAndSync().then(() => {
    let userInstance = Users.create({ username: 'test@gmail.com', password: 'pass' });

    userInstance.save().then(resource => {
        console.log("I'm a mysql row", resource);
    });
});
1.0.33

7 years ago

1.0.32

7 years ago

1.0.31

7 years ago

1.0.30

7 years ago

1.0.29

7 years ago

1.0.28

7 years ago

1.0.27

7 years ago

1.0.26

7 years ago

1.0.25

7 years ago

1.0.24

7 years ago

1.0.23

7 years ago

1.0.22

7 years ago

1.0.21

7 years ago

1.0.20

7 years ago

1.0.19

7 years ago

1.0.18

7 years ago

1.0.17

7 years ago

1.0.16

7 years ago

1.0.15

7 years ago

1.0.14

7 years ago

1.0.13

7 years ago

1.0.12

7 years ago

1.0.11

7 years ago

1.0.10

7 years ago

1.0.9

7 years ago

1.0.8

7 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago