Pouchdb is an open source JavaScript database that can be run in a browser. Pouchdb's data storage and processing methods are inspired by Apache Couchdb (Couchdb is a document-oriented database that can be queried and indexed by JavaScript in a mapreduce way. It also provides two-way collision detection and resolution for incremental replication.
The goal of the POUCHDB project is to help developers build Web applications that are well-used both online and offline:
- When the application is offline, the user data can be saved locally;
- When the online status is restored, the data is synchronized with COUCHDB and other compatible servers.
In this way, consistent data can be seen regardless of where the user is logged on or what device they are using.
Like an offline version of Gmail or Evernote apps, you can edit content anywhere, anytime, online or offline, and sync automatically the next time you log in, and you can ensure that offline content that was previously saved on different devices does not conflict when you sync.
The sample code is as follows:
JavaScript code
- var db = new POUCHDB ( ' dbname ');
-
- Db.put ({
- _id:
- name:
- age: 66
- });
-
- db.changes ({
- onchange: < span class= "keyword" >function () {
- console.log ( ' ch-ch-changes ');
- }
- });
-
- db.replicate.to ( ' Http://example.com/mydb ');
POUCHDB based on the Apache 2.0 Open source protocol, the code is hosted on GitHub: HTTPS://GITHUB.COM/DALEHARVEY/POUCHDB
Official website: http://pouchdb.com/
Document: Http://pouchdb.com/learn.html
POUCHDB: Open source JavaScript database that can be synced at any time