cordova - Architecture of an app when using CouchDB/PouchDB -
i wondering how architecture should when using pouchdb
local storage in mobile app instead of localstorage
.
at moment used cache app's data localstorage
, when needed perform api call backend request or post data. backend holding logic. such as:
- does user has correct permission/role action?
- any other logic needed check if action can done
all data stored relational database. have been reading nosql databases , in particular couchdb
, pouchdb
. wondering how architecture like? 3 questions arise @ point me:
- if have multiple users there own authentication, how can make sure users access data? , still have 1 database on server end?
pouchdb
on client side can in sync remotepouchdb
. when application build javascript how make sure people not inserting datapouchdb
'hacking' client-side javascript?- would use of backend gone in these kinds of setups? , if want have api
3rd party
, put examplesails.js
backend aroundcouchdb
?
pouchdb maintainer here, happy answer questions. :)
if have multiple users there own authentication, how can make sure users access data? , still have 1 database on server end?
there guide in the pouchdb-authentication readme. cloudant , couchbase have own systems managing users.
pouchdb on client side can in sync remote pouchdb. when application build javascript how make sure people not inserting data pouchdb 'hacking' client-side javascript?
you write validate_doc_update function on server side. when pouchdb tries sync couchdb, failed documents emit 'denied'
event, , documents not sync.
as local database, cannot prevent users writing bad data (they can open console , whatever want), can use pouchdb-validation
re-use validation function on client side. or can when put()
document.
would use of backend gone in these kinds of setups? , if want have api 3rd party, put example sails.js backend around couchdb?
some people write pouchdb apps without backend (just using pure couchdb/cloudant/couchbase), whereas others mix database server architecture of choice. it's you. :)
one interesting solution if you're using express use express-pouchdb, can expose pouchdb server-like endpoint inside of existing architecture. sails.js, though, you'd have write own.
Comments
Post a Comment