egg-psyduck-sqlite

1.0.1 • Public • Published

egg-psyduck-sqlite

Egg plugin for sqlite

安装

$ npm i egg-psyduck-sqlite --save

支持的 egg 版本

egg 3.x egg 2.x egg 1.x
😁 😁

开启插件

// {app_root}/config/plugin.js
exports.sqlite = {
  enable: true,
  package: "egg-psyduck-sqlite",
};

配置

// {app_root}/config/config.default.js
config.sqlite = {
  default: {
    path: ":memory:",
    options: null,
  },
  // 单实例
  client: {
    path: ":memory:",
    options: null,
  },
  // 多实例
  clients: {
    db1: {
      path: ":memory:",
      options: null,
    },
  },
};

示例

const db1 = app.sqlite.get("db1");
// 获取数据库连接对象
const connection = db1.connection;
// 运行 SQL
await db1.run(sql);
// 单条查询
await db1.select(sql);
// 多条查询
await db1.selects(sql);
// 插入
await db1.insert(sql);
// 更新
await db1.update(sql);
// 删除
await db1.del(sql);
// 简单事务
await db1.transaction([sql1, sql2, sql2]);

License

MIT

Package Sidebar

Install

npm i egg-psyduck-sqlite

Weekly Downloads

1

Version

1.0.1

License

MIT

Unpacked Size

17 kB

Total Files

5

Last publish

Collaborators

  • undsky