#103 PouchDB

PouchdDB is a client-side database that can easily be synced to a remote CouchDB database instance.  This opens up a ton of opportunities for rapidly building apps without writing server code.

You can use PouchDB in ember using the ember-pouch addon:

Generate an application adapter:

Configure your local database in config/environment.js:

Now add this property to all your models:

Use ember data as you always have and your data will be saved locally.  I tried this in Chrome and my data was saved in IndexDb:

This tip just gets you started and I recommend you head over to https://github.com/nolanlawson/ember-pouch to learn a ton more including how to automatically sync with a remote database, handle relationships and more.

PS: I got a tip from Martin Broerse that you can check if you are offline by checking for the “paused” state.  As an example, he suggested checking the website https://bloggr.exmer.com/posts and noticing how the green up arrow turns red when you turn off your wifi.

Published by

Emad Ibrahim

Author of asp .net MVC & TDD, entrepreneur, passionate technologist, programmer and productivity nut. more at http://t.co/oSJXPvzu