# uni-runtime-adapter **Repository Path**: myzero1/uni-runtime-adapter ## Basic Information - **Project Name**: uni-runtime-adapter - **Description**: uni运行环境适配 - **Primary Language**: NodeJS - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-03-16 - **Last Updated**: 2021-04-11 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # uni-runtime-adapter #### 介绍 uni运行环境适配:使用这个module可以简单的兼容unicloud和本地nodejs运行环境。可以在本地直接使用uni-cloud-router。也可以使用uniCloud云函数操作数据库的接口 已经兼容的数据库接口 [uniCloud/cf-database](https://uniapp.dcloud.io/uniCloud/cf-database) | 类型 | 接口 | 说明 | ---- | ---- | ---- | | [v]写 | add | 新增记录(触发请求) | | [v]计数 | count | 获取符合条件的记录条数 | | [v]读 | get | 获取集合中的记录,如果有使用 where 语句定义查询条件,则会返回匹配结果集 (触发请求)| | [v]查询条件 | where | 通过指定条件筛选出匹配的记录,可搭配查询指令(eq, gt, in, ...)使用| | [v]查询条件 | skip | 跳过指定数量的文档,常用于分页,传入 offset | | [v]查询条件 | orderBy | 排序方式 | | [v]查询条件 | limit | 返回的结果集(文档数量)的限制,有默认值和上限值 | | [v]field | field | 指定需要返回的字段 #### 软件架构 软件架构说明 #### 安装教程 `uni-runtime-adapter` #### 使用说明 1. 直接在入口文件中配置,如下 index.js ```code 'use strict'; const { Router } = require('uni-cloud-router') // uniRuntimeAdapterDb 需要放到uni-cloud-router加入之后 require('uni-runtime-adapter').uniRuntimeAdapterDb({ "protocol": "mongodb", "host": "localhost", "port": "27017", "database": "test", "username": "", "password": "" }) const router = new Router(require('./config.js')) exports.main = async (event, context) => { return router.serve(event, context) }; // require('uni-runtime-adapter').uniRuntimeAdapter({ // "web": { // "mainFunc": exports.main // }, // "db": { // "protocol": "mongodb", // "host": "localhost", // "port": "27017", // "database": "test", // "username": "", // "password": "" // }, // }) // uniRuntimeAdapterWeb 建议放在最后面 require('uni-runtime-adapter').uniRuntimeAdapterWeb({ "mainFunc": exports.main }) ``` 2. 参数说明 ```code require('uni-runtime-adapter').uniRuntimeAdapter({ "web": { "mainFunc": exports.main // 保持不变 }, "db": { // 目前只支持mongodb "protocol": "mongodb", "host": "localhost", "port": "27017", "database": "test", "username": "", // username和password同时非空才会启动用户验证 "password": "" }, }) ``` #### 参与贡献 1. Fork 本仓库 2. 新建 Feat_xxx 分支 3. 提交代码 4. 新建 Pull Request #### 特技 1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md 2. Gitee 官方博客 [blog.gitee.com](https://blog.gitee.com) 3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解 Gitee 上的优秀开源项目 4. [GVP](https://gitee.com/gvp) 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目 5. Gitee 官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help) 6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/) #### 更新日志 1. v1.0.4 开始可以正常使用,对应的 mongodb module 版本为 `3.6.4` 2. v1.1.0 能在生产环境使用,对应的 mongodb module 版本为 `3.6.4` 3. v1.1.2 对应的 mongodb module 版本为 `3.6.4`;修复缺少 koa