将复杂类型存储在Fluf sqflite中 [英] Store complex type in flutter sqflite

查看:243
本文介绍了将复杂类型存储在Fluf sqflite中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如如何在sqflite中存储复杂类型: 餐桌上的人(身份证,姓名,电子邮件,汽车列表); 汽车在哪里是具有ID和类型的实体? 有什么解决方案,例如如何存储它(例如Blob或在新表中并将其链接到人员表)?

how to store complex type in sqflite for example : the table person(id,name,email,List cars); where the car is an entity that have an id and a type ? is there any solution like how to store it (like a Blob or in a new table and link it to the person table ) ?

推荐答案

您不能在一个简单的表中.我了解您的意思,例如,您想存储以下内容:

You can´t in a simple table. I understand your point, you want to store, for example, something like this:

citizen = {
  "name":"",
  "id":"",
  "childrens":{
     children1:{
       "name":"",
       "id":"",
     }
     children2:{
       "name":"",
       "id":"",
     }
  }
}

这是因为sqflite是使用设备sqlite的工具,并且该数据库在apache软件下工作.这意味着Sqflite会存储数据,而sql DB会存储数据,而您不能在sql表中存储对象.

This is because sqflite is a tool to use the device sqlite and this DB works under apache software. That means, Sqflite stores data as well sql DB stores data and you can't store objects in a sql table.

您应根据需要为每个复杂数据创建其他表.像这样的东西(作为伪代码):

You should create other table for each complex data as you need. Something like this (as pseudocode):

'CREATE TABLE Citizen ('
          ' id INTEGER PRIMARY KEY,'
          ' name TEXT,'
          ' children1Id INTEGER,'
          ' children2Id INTEGER,'
          '); '
'CREATE TABLE Children ('
          ' id INTEGER PRIMARY KEY,'
          ' name TEXT'
          ')'

我希望这会对您有所帮助.

I hope this will help you.

这篇关于将复杂类型存储在Fluf sqflite中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆