Cordova/Phonegap ORM? - sqlite

Are there any ORM javascript projects compatible with Cordova, like ORMLite? I did a google search, github search, searched here, and couldn't find any.
If not, maybe it's time to start one.

This old but I stumbled upon it so others might too... what ended up working for me was using the Cordova SQLite plugin for a db with no size limit and the Persistence.js ORM to work with it.

This question is old, but there is also Persistence.js which I actually ended up using. It has it's own drawbacks, but every ORM does.
It would actually use the HTML5 storage on the phone. This is limited to 5mb per the specification, but obviously individual vendors may not enforce or follow this limit.

Yes there is an Open Source Framework, known as Siminov Hybrid, it provides ORM for both Android Native (Java) and Web (JavScript). It is easily configurable which works for both Native and Web at same time.
Works with Phonegap and later it will be support on other frameworks also.
http://siminov.github.io/android-hybrid

I do not know why there is no official ORM for sqlite with cordova though it is very required !
Anyway as time of writing this , you have the below option :
1- typeorm with angularjs2 ( they promised to provide support for sqlite )
2- ionic2-orm it is a fork of the previous point , however it look like there is no support till now
3-ionic2-orm2 which is a fork of the previous point also ( duh.. ) you can access it on this one https://github.com/sidneycorreia/ionic-orm
4- the best option up to this point is pouchdb check this one https://pouchdb.com/

Related

Ionic 2 storage module clarification

There is a lot of confusion when it comes to ionic 2 storage. There was a lot of changes in the new ionic version as Storage was moved to #ionic/strage . I am new to Ionic so some of the things are confusing for me. I have web-development background. From the documentation,
A simple key-value Storage module for Ionic apps based on LocalForage,
with out-of-the-box support for SQLite. This utility makes it easy to
use the best storage engine available without having to interact with
it directly. Currently the ordering is SQLite, IndexedDB, WebSQL, and
LocalStorage.
Installation
npm install #ionic/storage
If you'd like to use SQLite as a storage engine, install a SQLite plugin (only works while running in a simulator or on device):
cordova plugin add cordova-sqlite-storage --save
What I would like to know is, what happens when I run this in browser ? Where does it store the data? What would happen if I dont use cordova-sqlite-storage ? Where does it store the data then?
Ionic also supports SQLite plugin natively to store data in SQLite database .
import { SQLite } from 'ionic-native'
How is it different from Storage other than the fact that there is a fallback to IndexedDB, WebSQL, and LocalStorage ?
I hope my thoughts are in the right direction. A clear answer on how these modules work would be really helpful.
Ionic Storage is the first module written with proper web fallback in mind.
One near-term goal we have with Ionic is enabling devs to build 99% of their app in the browser. It's a much faster workflow. This means support for native plugins that have web fallbacks, as well as better mocking for ones that don't. - Max Lynch on Twitter
By default when running, #ionic/storage will prioritize the storage methods this way:
When running in a native app context, Storage will prioritize using
SQLite, as it's one of the most stable and widely used file-based
databases, and avoids some of the pitfalls of things like localstorage
and IndexedDB, such as the OS deciding to clear out such data in low
disk-space situations.
When running in the web or as a Progressive Web App, Storage will attempt to use IndexedDB, WebSQL, and localstorage, in that order.
- Official Documentation
So when your app is running in the browser (or on a device without the SQLite plugin) it will detect that SQLite is not available and will use IndexedDB/WebSQL instead.
How is it different from Storage other than the fact that there is a fallback to IndexedDB, WebSQL, and LocalStorage?
The SQLite plugin gives you low-level access to an SQLite database, which means you have to care about creating/updating your schemas, and write queries.
#ionic/storage is a wrapper which abstract away the differences of LocalForge and SQLite and provide a simple, unified API to store key/value pairs.
Also it takes care of serializing/deserializing of your objects.
From my understanding of the Ionic 2 RC Storage module, when you are running in the browser you are now only able to store key-value pairs (LocalStorage). You are currently not able to store anything more than that, so you should check out other options like PouchDB and LocalForage if you need full SQL support. This definitely isn't ideal for progressive web apps.

Monaca implementation of SQLite - Native via Cordova or Deprecated Web SQL?

So basically like the title says, does Monaca implement local storage database as SQLite using the native implementation via Cordova's sqlite plugin or does it rely on the deprecated use of Web SQL standard?
The Monaca docs here:
http://docs.monaca.mobi/cur/en/sampleapp/tips/storage/#creating-a-database-sqlite
Show that it is SQLite using the deprecated Web SQL standard: window.openDatabase
I would assume Monaca would actually be using Cordova implementation of native SQLite via the plugin but I cannot find it in the plugin manager nor do the docs support the implementation syntax of: window.sqlitePlugin.openDatabase
Either way, what would be the best practice use of SQLite in an app? My fear is to use what is documented (I think deprecated) and then next version have to recode everything when the Cordova plugin implements SQLite in native already.
Thanks!
XPost from here: https://community.onsen.io/topic/216/monaca-implementation-of-sqlite-native-via-cordova-or-deprecated-web-sql/2
#munsterlander this is a very good question! I actually didn’t know that Web SQL was deprecated. At the moment, Monaca includes just Web SQL plugin but the native Cordova plugin can be imported with a developer or higher plan and should work without any issue.
We will discuss about integrating the new plugin in Monaca but I cannot say when it will happen.
I don’t think you will have any issue with Web SQL but, of course, it’s better to use the native plugin.

MvvmCross Async SQLite

I'm starting to rebuild my app to MvvmCross, but I hit a small roadblock. It seems the community plugin for SQLite doesn't support async connection and querying. WinRT requires data access and other long-running operations to be performed asynchrnously, so this seems like an issue (although I think it is safe to say, that normal operations won't take that long to make this matter). I just wanted to ask, if asynchronous support is somehow possible to add and if this feature will be somehow added in future releases.
Thank you all very much!
Don't use the mvvmcross sqlite plugin. Instead use the PCL compatible "sqlite.net pcl". It has both sync and async versions.
github:
https://github.com/oysteinkrog/SQLite.Net-PCL
nuget:
http://www.nuget.org/packages/SQLite.Net-PCL/
The cg+sql branch of my fork contains provisions to use Async in mvvmcross-sqlite
https://github.com/loqu8/mvvmcross-sqlite/tree/cg+sql
Take a look and see if it works for you. It is based on sqlite-net Async.
Please look at TODOs in MvvmCross Sqlite-Net (https://github.com/MvvmCross/MvvmCross-SQLite) readme file. The first one:
add Async - #Praeclarum and #Jarroda have already done the 'hard work'
- we just need to work out how to include it - do we switch to Profile78? Do we drop WP7.5? Do we hack in AsyncBridge somehow?
So it seems that we will get Async support some day and will get even more fun from using MvvmCross! :-)
For now it seems that the only solution is to create low-level data access interface with save/load/find methods and implement it in platform-specific projects.

What storage type do I use now since websql is deprecated?

WebSQL is deprecated now and IndexedDB wasn't implemented to cordova yet. So, what storage type you are using, guys?
I think to use a Native SQLite Android Plugin, but I don't know if is the only and best way.
I suggest you to keep using WebSQL for the moment.
you should build a separated js wrapper to your db, so it will be easy to replace when time comes.
but for the moment- it works and supported by the mobile browsers, and threfore you have nothing to worry about.
you can read this discussion:
https://groups.google.com/forum/#!topic/persistencejs/KYSWQ1H8hL0
also, keep in mind that if you intend to use plugin for native storage, you will not be able to use Phonegap Build, so you may want to consider it.

is there an SQLite-based wiki?

I would like to find out if there is wiki software that runs on SQLite.
Sure is.
Instiki
Instiki (What Is Instiki) is a basic
Wiki clone so pretty and easy to set
up, you’ll wonder if it’s really a
wiki. Runs on Rails and focuses on
portability and stability. Supports
file uploads, PDF export, RSS,
multiple users and password
protection. Some use Instiki as a CMS
- Content Management System because of its ability to export static pages.
Fossil, which is a DVCS with many other features (including a wiki) is built on top of Sqlite (in face, made by D. Richard Hipp who wrote Sqlite ). It can be found at: http://www.fossil-scm.org/index.html/doc/tip/www/index.wiki
According to the SQLite Users Page, the CVSTrac program is using SQLite as its internal database structure (you have to follow the link to the CVSTrac site to see the details). I'm sure there are others by hunting around the site.
Wiki::Toolkit can use SQLite as its database.
Mediawiki does, but it is only in the development stage.
Any of the Django ones should be able to, because Django is flexible about which Database backend it uses and SQLite is one of the options.

Resources