代码拉取完成,页面将自动刷新
数据库特性:
直接通过API文档构建请求即可
初始化连接
// 引入模块
// for browser
<script src="/socket.io/socket.io.js"></script>
// for nodejs
const io = require('socket.io-client')
// 建立连接
const client = io('http://127.0.0.1:7170')
client.on('connect', () => {
// 连接成功
})
初始化表结构
curl -X POST http://127.0.0.1:7170/createTable -d '{"ns": "tt.test", "cols": {}}'
client.emit('createTable', 'tt.test', {
name: { len: 10, type: 'string', encoding: 'utf8'},
uptime: { type: 'double'},
test: { len: 20, type: 'string', encoding: 'utf8'},
rand: { len: 20, type: 'string', encoding: 'utf8'},
bool: { type: 'bool', default: false },
int: { len: 2, type: 'int' }, // int len: 1-6, 1: 128, 2: 128 * 256, 3: 128 * 256 * 256
time: { type: 'time' },
date: { len: 20, type: 'string', encoding: 'utf8'}
}, { update: true })
插入数据
http://127.0.0.1:7170/tt.test/create?name=hehe&rand=165
test.create({
name: 'test',
uptime: 1.23123,
test: 'hehedada',
rand: '371893',
bool: true,
int: Acan.random(0, 99),
time: 1592188598,
date: '2020-06-15 10:36:56'
})
查询数据
http://127.0.0.1:7170/tt.test/find?name=hehe&rand[$like]=165&$limit=10&$skip=0
test.find({
name: 'test', // 全等于查询
test: { $like: ['hehe', 'dada'] } // like模糊查询, 支持数组传入
rand: { $in: ['123456', '234567'] } // 数组全等于查询
}, { limit: 10, skip: 0 })
查询单条数据
http://127.0.0.1:7170/tt.test/findOne?name=hehe&rand[$like]=165&$skip=0
test.findOne({
name: 'test', // 全等于查询
test: { $like: ['hehe', 'dada'] } // like模糊查询, 支持数组传入
rand: { $in: ['123456', '234567'] } // 数组全等于查询
}, { skip: 0 })
统计数据量
http://127.0.0.1:7170/tt.test/count?name=hehe&rand[$like]=165
test.count({
name: 'test', // 全等于查询
test: { $like: ['hehe', 'dada'] } // like模糊查询, 支持数组传入
rand: { $in: ['123456', '234567'] } // 数组全等于查询
})
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。