bjchy-udg-sdk 1.4.3 → 1.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +9 -0
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -372,3 +372,12 @@ if (client.now() < new Date(activity.bookEnd)) { /* 可以报名 */ }
372
372
  - 日期:SDK 与 Gateway 以 `{ $date: 毫秒 }` 传输,业务代码直接用 `Date` 对象读写即可
373
373
  - `db.serverDate()` V1 以客户端时间近似;需要可信的“当前时间”用 `client.now()`,需要不可伪造的“写入时间”用 Gateway 的 `beforeWrite.autoTimestamps` 钩子
374
374
  - distinct / 文件上传:V1 不提供
375
+ - 集合是首次写入时自动创建的(CloudBase 端也一样,Gateway 会代建并放开集合权限)
376
+ - **建/删索引、删集合**:SDK 不提供(属 DDL 运维动作)。用 Gateway 的 Admin 面接口 `POST /api/execute` + 请求头 `X-Admin-Key`,`action` = `createIndex` / `dropIndex` / `listIndexes` / `dropCollection` / `createCollection`,仅 mongodb / cloudbase 数据源可用。例:
377
+
378
+ ```bash
379
+ curl -X POST https://udg.vule.cn/api/execute -H 'X-Admin-Key: <ADMIN_KEY>' -H 'Content-Type: application/json' \
380
+ -d '{"action":"createIndex","appid":"bwds","db":"hjl","collection":"events","keys":{"street":1,"createdAt":-1},"unique":true}'
381
+ ```
382
+
383
+ `keys` 也可写成 `[{"name":"street","direction":1}]`;方向支持 `1/-1/2d/2dsphere/text/hashed`;不传 `name` 时按 MongoDB 惯例生成索引名;重复创建幂等。`dropCollection` 删非空集合必须显式带 `force:true`(否则报错并告知集合内文档数)。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bjchy-udg-sdk",
3
- "version": "1.4.3",
3
+ "version": "1.4.4",
4
4
  "description": "Universal Data Gateway SDK - 跨端统一数据访问(微信小程序 / Web / Node.js),API 兼容微信云开发",
5
5
  "main": "src/index.js",
6
6
  "type": "commonjs",