SQLite vs LocalStorage与Ionic/Firebase [英] SQLite vs LocalStorage with Ionic/Firebase

查看:83
本文介绍了SQLite vs LocalStorage与Ionic/Firebase的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用Ionic 2编写一个聊天应用程序.我想将一些消息保存在手机本地.

I am writing a chat app in Ionic 2. I want to save some of the the messages locally on the phone.

我正在使用Firebase作为消息传递系统.它以JSON表示法存储消息.阅读邮件时,我想将其存储在本地并将其从Firebase删除

I am using Firebase as the messaging system. It stores the messages in JSON notation. When I read a message I want to store it locally and delete it from Firebase

我应该使用SQLite还是本地存储?

Should I use SQLite or Local Storage?

我通常会说SQLite是因为它更可靠,但是由于Firebase使用JSON,我是否应该将本地消息作为JSON存储在本地存储中?

I would normally say SQLite bexcuse it's more reliable, but because Firebase uses JSON, should I rather store the local messages as JSON in Local Storage?

任何建议表示赞赏.

推荐答案

由于您使用的是Ionic,因此建议您使用离子存储模块.

Because you are using Ionic, I would suggest that you use the ionic-storage module.

默认情况下,它使用可用的最先进的存储机制.因此,在Chrome中,它将使用IndexedDB并回退到WebSQL或LocalStorage.

By default it uses the most advanced storage mechanism available. So in Chrome, it will use IndexedDB and fall back to WebSQL or LocalStorage.

如果安装了cordova-sqlite-storage插件,则在设备上运行时,ionic-storage将使用sqlite作为存储引擎.

If you install the cordova-sqlite-storage plugin, ionic-storage will use sqlite as the storage engine when running on the device.

您只能使用ionic-storage存储键值对,因此不能使用自定义sql查询.但是存储JSON无需任何修改即可.

You can only store key-value pairs using ionic-storage, so you can't use custom sql-queries. But storing JSON works without any modifications.

这篇关于SQLite vs LocalStorage与Ionic/Firebase的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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