Code Monkey home page Code Monkey logo

orm's Introduction

@kaishen/orm

It is written in JavaScript. crud for mysql.

install:

npm install @kaishen/orm --save
or
yarn add @kaishen/orm

Use:

//import
import orm from '@kaishen/orm';

//require
let orm = require('@kaishen/orm');

Config initialization:

// You can initialize the configuration at project startup
const database = new orm({
    host: 'localhost',
    username: 'root',
    password:'123456',
    database: 'test',
    port: 3306,
});

configs

  • host: host address. (default:'127.0.0.1')
  • user: user. (default:'root')
  • password: password. (default:'root')
  • database: database. (default:'test')
  • port: port. (default:'3306')

Simple usage of generating SQL statements.

select

database.table('players')
    .select()
    .column('id')
    .column('name')
    .where('id = ?', 100)
    .finish()
    .exec();

select id, name from players where id = 100;

insert

database.table('players')
    .insert()
    .values({id: '100', name: 'kai'})
    .finish()
    .exec();

insert into players (id, name) values('100', 'kai');

update

database.table('players')
    .update()
    .set({name: 'kai2'})
    .where('id = ?', 100)
    .finish()
    .exec();

update players set name='kai2' where id = 100;

delet

database.table('players')
    .delete()
    .where('id = ?', 100)
    .finish();

delete from players where id = 100;

orm's People

Watchers

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