@alipay/faas-db-builder

v1.1.30
  • Types
  • ESM
  • CJS
License
MIT
Deps
0
Install Size
305.1 kB/-
Vulns
0
Published

Get started

$npm install @alipay/faas-db-builder
$pnpm add @alipay/faas-db-builder
$yarn add @alipay/faas-db-builder
$bun add @alipay/faas-db-builder
$deno add npm:@alipay/faas-db-builder
$vlt install @alipay/faas-db-builder

Readme

@alipay/faas-db-builder

db 调用参数解析器

用法示例

import { MongoBuilder } from '@alipay/faas-db-builder';

const db = new MongoBuilder();

// 获取查询 collection 列表的 mongo 请求参数
const res1 = db.listCollection(123, 456);

assert.deepStrictEqual(res, {
  // 查询列表操作
  action: 'queryList',
  // 参数详情
  options: {
    $limit: 123,
    $skip: 456,
  },
  // 操作对象为 collection
  target: 'collection',
});

// 获取在名为 'todo' 的 collection 中添加 document 的 mongo 请求参数
const res2 = db.collection('todo').add({
  data: {
    text: 'hello mongo',
    done: false,
  },
});

assert.deepStrictEqual(res2, {
  // 新建操作
  action: 'create',
  // 目标 collection 名
  collectionName: 'todo',
  // 参数详情
  options: {
    done: false,
    text: 'hello mongo',
  },
  // 操作对象为 document
  target: 'document',
});

Weekly DownloadsAcross all versions

Node.js
>= 14.0.0

Versions

1.1.30
latest