# adb **Repository Path**: acans/adb ## Basic Information - **Project Name**: adb - **Description**: No description available - **Primary Language**: JavaScript - **License**: GPL-3.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 5 - **Forks**: 1 - **Created**: 2020-06-03 - **Last Updated**: 2024-04-18 ## Categories & Tags **Categories**: javascript-toolkits **Tags**: None ## README ## ADB > 数据库特性: - 集时序(按时间快存储)、列数据库(列独立存储),热区读写(只有热区数据可以写入)特性于一体 - 插入性能超高(单核可达 20万/s,基于 Ubuntu + AMD Ryzen5 3500U 测试环境得出) - 多条件查询极快(采用索引交替查询法,查询栏目越多越快) - LIKE模糊查询极快(直接使用二级制检索,模糊查询效率高于全等于查询) - 内存管理灵活,内存占用低(每个表可独立管理内存使用情况) - 支持zstd压缩,磁盘存储节省10倍以上 - 采用 REST API 作为接入端,接入零成本 ## 接入方式 ### Rest Api > 直接通过API文档构建请求即可 ### socket.io > 初始化连接 ```js // 引入模块 // for browser // for nodejs const io = require('socket.io-client') // 建立连接 const client = io('http://127.0.0.1:7170') client.on('connect', () => { // 连接成功 }) ``` ## API ### createTable(db.table, cols, opt) > 初始化表结构 ```rest api curl -X POST http://127.0.0.1:7170/createTable -d '{"ns": "tt.test", "cols": {}}' ``` ```js 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 }) ``` ### create > 插入数据 ```rest api http://127.0.0.1:7170/tt.test/create?name=hehe&rand=165 ``` ```js 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' }) ``` ### find > 查询数据 ```rest api http://127.0.0.1:7170/tt.test/find?name=hehe&rand[$like]=165&$limit=10&$skip=0 ``` ```js test.find({ name: 'test', // 全等于查询 test: { $like: ['hehe', 'dada'] } // like模糊查询, 支持数组传入 rand: { $in: ['123456', '234567'] } // 数组全等于查询 }, { limit: 10, skip: 0 }) ``` ### findOne > 查询单条数据 ```rest api http://127.0.0.1:7170/tt.test/findOne?name=hehe&rand[$like]=165&$skip=0 ``` ```js test.findOne({ name: 'test', // 全等于查询 test: { $like: ['hehe', 'dada'] } // like模糊查询, 支持数组传入 rand: { $in: ['123456', '234567'] } // 数组全等于查询 }, { skip: 0 }) ``` ### count > 统计数据量 ```rest api http://127.0.0.1:7170/tt.test/count?name=hehe&rand[$like]=165 ``` ```js test.count({ name: 'test', // 全等于查询 test: { $like: ['hehe', 'dada'] } // like模糊查询, 支持数组传入 rand: { $in: ['123456', '234567'] } // 数组全等于查询 }) ```