Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70439

SQLite and Native Storage question truly relational?

$
0
0

@ctfrancia wrote:

Right guys, so I read the docs (or lack there of[don’t worry once I understand better I hope to improve them]) in terms of the local Storage or rather SQLite. I am writing a native app and installed ionic cordova plugin add cordova-sqlite-storage and npm install --save @ionic/storage as it says on the docs. Now, it says that it will choose the best db depending on the platform. This is cool, however, the part that kinda has me scratching my head is are some of those methods that are listed applicable to all?
I am writing a chat application and need to store the messages in a SQLite file. What it appears to me is that I will need to be using more of an ORM than a raw SQL queries? my chat sql “table” will look something like

{
  conversations: [
    {id: 1, person: "Christian", messages: [{}, {}, {}]},
    {id: 2, person: "Laura", messages: [{}, {}, {}]
  ]
}

As you can see, clear, get, forEach, set, keys, length, ready, and remove is just not going to cut it. For every new message that comes in it looks like I will have to forEach() and store all the objects in a new message array then set() a new object after a certain amount of time, which seams barbaric. Where with a relational DB I could do something like INSERT INTO messages WHERE id=id or something similar and maintain foreign keys. Is there more documentation somewhere that will allow me to do something like this?

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 70439

Trending Articles