扫一扫分享
Vasern是react Native的数据存储,下面是链接一致的键值存储。它的数据引擎是本地构建的,以实现本机性能。我们的目标是开发一个开源,开发人员友好的端到端数据库解决方案。Vasern beta 适用于iOS和Android。它经过严格测试,以确保其功能,数据质量和一致性。
import Vasern from 'vasern';
// Define Todos application schema
const VasernDB = new Vasern({
schemas: [{
name: "Users",
props: {
fname: "string",
lname: "string"
}
},{
name: "Todos",
props: {
name: "string",
completed: "boolean",
assignTo: "#Users"
}
}]
});
// Add listener whenever Todos has a change (loaded/insert/update/delete)
VasernDB.Todos.onChange(() => {
// Get all todo items with "completed" is "false"
const todoList = VasernDB.Todos.filter({ completed: false });
// Update state
this.setState({ data: todoList.data() });
})
手机预览