|
|
1 year ago | |
|---|---|---|
| .. | ||
| ObjectId | 1 year ago | |
| commands | 1 year ago | |
| config | 1 year ago | |
| const | 1 year ago | |
| geo | 1 year ago | |
| helper | 1 year ago | |
| realtime | 1 year ago | |
| regexp | 1 year ago | |
| serializer | 1 year ago | |
| serverDate | 1 year ago | |
| transaction | 1 year ago | |
| typings | 1 year ago | |
| utils | 1 year ago | |
| README.md | 1 year ago | |
| aggregate.ts | 1 year ago | |
| collection.ts | 1 year ago | |
| command.ts | 1 year ago | |
| constant.ts | 1 year ago | |
| document.ts | 1 year ago | |
| index.ts | 1 year ago | |
| operator-map.ts | 1 year ago | |
| query.ts | 1 year ago | |
| transaction.ts | 1 year ago | |
| util.ts | 1 year ago | |
| validate.ts | 1 year ago | |
@author haroldhu
[TOC]
- collection.ts // 集合模块,继承 Query 模块
- constant.ts // 常量模块
- db.ts // 数据库模块
- document.ts // 文档模块
- model.ts // 类型约束模块
- query.ts // 查询模块
- request.ts // 请求模块 - 临时模拟使用
- util.ts // 工具模块
- validate.ts // 校验模块
# 编辑 typescript
tnpm run tsc
# 实时编译 typescript
tnpm run tsc:w
# 运行测试用例
tnpm run tstest
类型声明写在.ts文件里,这样可以及时发现问题。.d.ts不能及时暴露问题。
集合模块继承 Query 模块,为了更好使用查询条件。
主要参考了 firebase - firestore 的设计。
拉取文档列表后,过滤一遍数据,把特殊类型的字段格式化为相应的js对象。
发送请求新增或更新文档时,过滤一遍数据,把特殊字段编码为后端数据格式。
每一个地理位置都是一个GeoPoint对象。
这个开发者用不到,所以没有必要暴露出来。
每一个日期时间都是一个Date对象。
document.get()获取数据时,把where()、orderBy()、limit()、offser()、设置的数据拼接到请求里。DocumentSnapshot对象,对特殊类型的字段,如地理位置、日期时间进行处理。document.set()和document.update()时,把数据进行编码,尤其是特殊字段的处理,编码成后端接口的数据格式。开发者可以在每篇文档里记录创建时间和更新时间。