@lcap/asl
Version:
NetEase Application Specific Language
58 lines (47 loc) • 975 B
Markdown
# Development
开发时,这块尽量能够单独发包。
## 规范
- 为了兼容 Vue,属性至少全部声明 undefined
- 都声明 constructor
- 按 JSON 创建节点时,优先使用 from
- 添加和删除操作,先请求再变更;设置属性的话,简单一些先修改数据再请求
- 发送请求处理数据,返回时按最小情况 pick
### 增删改查定义方式
#### 增1
```
const entity = new Entity({
serviceId: '292c8df3-a74b-4434-83ec-14eb7798bc5e',
...
});
await entity.create();
```
#### 增2
```
await service.addEntity(entityOptions);
```
#### 删1
```
await entity.delete();
```
#### 删1
```
await service.removeEntity(entity);
```
#### 改1
```
entity.assign({ name: 'bbb' });
entity.update();
```
#### 改2
```
entity.setName('bbb');
```
#### 查
```
const entity = new Entity({ id: 'e457acee-d69b-4f5b-bbe5-64ac8fdbf7ce' });
entity.load(); => handle
```
#### [v] 查列表
```
service.loadEntities(); => handle
```