基于 Rust 实现的去中心化数据库 DB3 Netwrok v0.2.9 发布

科技资讯 投稿 15300 0 评论

基于 Rust 实现的去中心化数据库 DB3 Netwrok v0.2.9 发布

项目介绍

db3 network 是一款开源去中心化 firebase 实现

v0.2.9 版本主要更新

命令更新

添加支持对文件简单查询和现实网络状态命令

db3>-$ show-doc --addr 0xf462aa8c93d924d2100de9a1bbaad15d04b29f30 --collection-name books --filter '{"field": "age", "value": 44, "op": "=="}' --limit 1 id_base64                            | owner                                      | document                                                                                                              | tx_id --------------------------------------+--------------------------------------------+-----------------------------------------------------------------------------------------------------------------------+---------------------------------------------- AQAAAAAAAAGbAAEAAQAAAAAAAAHHAAEAAA== | 0x84b0bd55e7ad979b7cb92a56f561190de8f68403 | Document({"name": String("Mike", "age": Int64(44, "phones": Array([String("+44 1234567", String("+44 2345678"]} | OFXo7Z8FCn9eNNoosAbl7i2LmthDMUKh6Nr20rpAecQ=

现实网络状态

db3>-$ show-state
 name       | state
------------+---------
 database   | 1
 collection | 0
 documemt   | 0
 account    | 1
 mutation   | 1
 session    | 0
 storage    | 102.00

新增db3.js库

开发者可以直接使用typescript 对数据增删该查

// the key seed
const mnemonic ='...'
// create a wallet
const wallet = DB3BrowserWallet.createNew(mnemonic, 'DB3_SECP259K1'
// build db3 client
const client = new DB3Client('http://127.0.0.1:26659', wallet
const [dbId, txId] = await client.createDatabase(
// create a database
const db = initializeDB3('http://127.0.0.1:26659', dbId, wallet
// add an index to collection
const indexList: Index[] = [
            {
                name: 'idx1',
                id: 1,
                fields: [
                    {
                        fieldPath: 'name',
                        valueMode: {
                            oneofKind: 'order',
                            order: Index_IndexField_Order.ASCENDING,
                        },
                    },
                ],
            },
]
// create a collecion
const collectionRef = await collection(db, 'cities', indexList
// add a doc to collection
const result = await addDoc(collectionRef, {
    name: 'beijing',
    address: 'north',
}
// get all docs from collection                                                                                                                                                                  
const docs = await getDocs(collectionRef

db3 network 正处于开发过程中,如果你对去中心化数据库感兴趣或者想了解更多,欢迎到加入到 github 社区 ,给 db3 network 点赞支持

编程笔记 » 基于 Rust 实现的去中心化数据库 DB3 Netwrok v0.2.9 发布

赞同 (28) or 分享 (0)
游客 发表我的评论   换个身份
取消评论

表情
(0)个小伙伴在吐槽