0.5.6 • Published 3 years ago

xeasy-orm v0.5.6

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

xeasy-orm

便捷的orm,基于express搭建的简单易用的ORM

快速开始

npm install --save xeasy-orm
or
yarn add xeasy-orm

创建index.ts

import { useHttp } from 'xeasy-orm';

const app = useHttp({
    config: {
        port: 3000,
        debug: true,
    }
})

useHttp: 启动express服务 config为基本配置

  • port: 启动端口号
  • debug:启动日志模式

useHttp config

属性是否必填数据类型说明
config必填objectexpress基本配置
--port必填number启动端口号
--debug必填boolean是否启动debug模式
routes非必填Array<express.Router>需要加载的路由
hooks非必填objectexpress中间件
--befor非必填Array<express.RequestHandler>访问所有api前调用
--after非必填Array<express.RequestHandler>访问所有api后调用
knex非必填Array<Knex.Config> or Knex.Config创建knex对象,需要安装对应的数据库包

这样我们的服务便启动完成了

添加Knex初始化

使用

import {useKnex, getKnexMaster} from 'xeasy-orm';

// 读写分离模式的情况下,可以传递数组,数组的第一位为master数据库,用于写入操作
useKnex({
    client: 'mysql',
    connection: {
        host: 'localhost',
        user: 'root',
        password: 'password',
        database: 'app_test',
        port: 3306,
    }
});

// 使用useKnex获取client对象时,会默认逐个使用数据库连接
const userList = await useKnex().table('user').select(*);
// 使用master写入
await getKnexMaster().table('user').install({name: 'name'});

useKnex 创建knex连接

加入mongoSchema 用于快速创建schema类型,并生成对应的orm

0.5.1 添加knex事务操作

0.5.6

3 years ago

0.5.4

3 years ago

0.5.3

3 years ago

0.5.5

3 years ago

0.5.2

3 years ago

0.5.1

3 years ago

0.4.5

3 years ago

0.4.4

3 years ago

0.4.7

3 years ago

0.4.6

3 years ago

0.4.3

3 years ago

0.4.2

3 years ago

0.4.1

3 years ago

0.4.0

3 years ago

0.3.0

3 years ago

0.2.6

3 years ago

0.2.5

3 years ago

0.2.1

3 years ago

0.2.3

3 years ago

0.2.2

3 years ago

0.2.4

3 years ago

0.2.0

3 years ago

0.1.9

3 years ago

0.1.8

3 years ago

0.1.7

3 years ago

0.1.6

3 years ago

0.1.4

3 years ago

0.1.5

3 years ago

0.1.3

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.0.11

3 years ago

0.0.12

3 years ago

0.0.13

3 years ago

0.0.14

3 years ago

0.0.10

3 years ago

0.0.9

3 years ago

0.0.8

3 years ago

0.0.7

3 years ago

0.0.3

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.6

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago