AiPexBase CLI Skill
About AiPexBase
AiPexBase is a BaaS (Backend as a Service) platform that provides database, authentication, file storage, and other backend capabilities.
GitHub: https://github.com/kuafuai/aipexbase
Prerequisites:
- - Deployed AiPexBase service (to get baseUrl)
- API Key (obtained from service admin dashboard)
- Installed aipexbase-cli: INLINECODE0
Core command format:
CODEBLOCK0
Important: All commands must use the -c parameter to specify the configuration file!
Configuration File
Must create configuration file first (even an empty file is fine):
CODEBLOCK1
- - Configuration can be filled or updated through the
config command.
Command Reference
1. Configuration Management
CODEBLOCK2
2. Database Operations
Query:
CODEBLOCK3
Modify:
CODEBLOCK4
where operators:
| Operator | Description | Example |
|---|
| Direct value | Equal | INLINECODE3 |
| INLINECODE4 |
Greater than |
{"price": {"gt": 100}} |
|
gte | Greater than or equal |
{"age": {"gte": 18}} |
|
lt | Less than |
{"stock": {"lt": 10}} |
|
lte | Less than or equal |
{"score": {"lte": 60}} |
|
neq | Not equal |
{"status": {"neq": "deleted"}} |
|
like | Fuzzy match |
{"name": {"like": "Zhang"}} |
|
in | In array |
{"status": {"in": ["active", "pending"]}} |
|
between | Range |
{"price": {"between": [100, 1000]}} |
3. Application and Table Management
CODEBLOCK5
Field types:
| Type | Description | Type | Description |
|---|
| INLINECODE20 | Short text | INLINECODE21 | Password (encrypted) |
| INLINECODE22 |
Long text |
phone | Phone (validated) |
|
number | Integer |
email | Email (validated) |
|
decimal | Decimal |
images | Images |
|
boolean | Boolean |
files | Files |
|
date | Date |
videos | Videos |
|
datetime | Datetime |
quote | Reference |
4. User Authentication
CODEBLOCK6
5. File Upload
CODEBLOCK7
Parameter Specifications
JSON Format Requirements
Rules:
- 1. Use single quotes
'...' for outer layer - Use double quotes
"..." for inner layer - JSON must be valid
Correct examples:
CODEBLOCK8
Incorrect examples:
CODEBLOCK9
columns Format
CODEBLOCK10
Quick Example
CODEBLOCK11
AiPexBase CLI 技能
关于 AiPexBase
AiPexBase 是一个 BaaS(后端即服务)平台,提供数据库、身份验证、文件存储和其他后端能力。
GitHub: https://github.com/kuafuai/aipexbase
前置条件:
- - 已部署的 AiPexBase 服务(用于获取 baseUrl)
- API 密钥(从服务管理后台获取)
- 已安装 aipexbase-cli:npm install -g aipexbase-cli
核心命令格式:
bash
baas -c <配置文件> <命令> [选项]
重要提示:所有命令必须使用 -c 参数指定配置文件!
配置文件
必须先创建配置文件(即使是空文件也可以):
bash
echo {} > config.json
命令参考
1. 配置管理
bash
设置配置
baas -c config.json config --base-url http://localhost:8080 --api-key your-api-key
查看配置
baas -c config.json config --show
2. 数据库操作
查询:
bash
查询全部
baas -c config.json db list <表名>
等值查询
baas -c config.json db list <表名> --where {status: active}
比较查询
baas -c config.json db list <表名> --where {price: {gt: 100}}
多条件查询
baas -c config.json db list <表名> --where {price: {gte: 100, lte: 1000}, status: active}
分页查询
baas -c config.json db page <表名> --page-num 1 --page-size 20
排序查询
baas -c config.json db list <表名> --order created_at:desc
单条记录
baas -c config.json db get <表名> --where {id: rec_xxx}
修改:
bash
插入
baas -c config.json db insert <表名> --data {field1: value1, field2: value2}
更新
baas -c config.json db update <表名> --where {id: rec_xxx} --data {field1: new-value}
删除
baas -c config.json db delete <表名> --where {id: rec_xxx}
where 操作符:
| 操作符 | 描述 | 示例 |
|---|
| 直接值 | 等于 | {status: active} |
| gt |
大于 | {price: {gt: 100}} |
| gte | 大于等于 | {age: {gte: 18}} |
| lt | 小于 | {stock: {lt: 10}} |
| lte | 小于等于 | {score: {lte: 60}} |
| neq | 不等于 | {status: {neq: deleted}} |
| like | 模糊匹配 | {name: {like: Zhang}} |
| in | 在数组中 | {status: {in: [active, pending]}} |
| between | 范围 | {price: {between: [100, 1000]}} |
3. 应用和表管理
bash
创建应用
baas -c config.json manage create-app --name 应用名称 --user-id 用户ID
创建表
baas -c config.json manage create-table \
--app-id 应用ID \
--table-name 表名称 \
--columns [
{columnName: name, columnType: string, columnComment: 名称},
{columnName: age, columnType: number, columnComment: 年龄}
]
字段类型:
| 类型 | 描述 | 类型 | 描述 |
|---|
| string | 短文本 | password | 密码(加密) |
| text |
长文本 | phone | 电话(验证) |
| number | 整数 | email | 邮箱(验证) |
| decimal | 小数 | images | 图片 |
| boolean | 布尔值 | files | 文件 |
| date | 日期 | videos | 视频 |
| datetime | 日期时间 | quote | 引用 |
4. 用户认证
bash
登录
baas -c config.json login --phone 13800138000 --code 123456
登出
baas -c config.json logout
生成登录链接
baas -c config.json login-link --channel web --user-id user123
5. 文件上传
bash
baas -c config.json upload --file /path/to/file.jpg --table 表名称
参数规范
JSON 格式要求
规则:
- 1. 外层使用单引号 ...
- 内层使用双引号 ...
- JSON 必须有效
正确示例:
bash
✓ --data {name: 张三, age: 25}
✓ --where {status: active}
错误示例:
bash
✗ --data {name: 张三} # 外层不能使用双引号
✗ --data {name: 张三} # 内层不能使用单引号
columns 格式
json
[
{
columnName: 字段名称,
columnType: 字段类型,
columnComment: 字段描述
}
]
快速示例
bash
1. 创建配置文件
echo {} > config.json
2. 设置配置
baas -c config.json config --base-url http://localhost:8080 --api-key your-key
3. 创建应用
baas -c config.json manage create-app --name 我的应用 --user-id admin
4. 创建表
baas -c config.json manage create-table \
--app-id baas_xxx \
--table-name users \
--columns [{columnName: username, columnType: string, columnComment: 用户名}]
5. 插入数据
baas -c config.json db insert users --data {username: zhangsan}
6. 查询数据
baas -c config.json db list users --where {username: zhangsan}