{"library":"pouchdb","title":"PouchDB","description":"PouchDB is an open-source JavaScript database designed for offline-first web applications, enabling data storage directly in the user's browser (or Node.js environment) and seamless synchronization with CouchDB-compatible servers. Currently at stable version 9.0.0 (released May 24, 2024), the project releases major versions periodically, with patch releases addressing bugs and minor enhancements more frequently. Its key differentiators include its robust replication engine, automatic offline data handling, and its ability to work across various browser and Node.js environments without requiring a persistent network connection, providing a highly resilient and performant user experience even without network connectivity.","language":"javascript","status":"active","last_verified":"Wed Apr 22","install":{"commands":["npm install pouchdb"],"cli":null},"imports":["import PouchDB from 'pouchdb';","import PouchDB from 'pouchdb-browser';","import PouchDB from 'pouchdb';\nimport pouchdbAdapterIndexedDB from 'pouchdb-adapter-indexeddb';\nPouchDB.plugin(pouchdbAdapterIndexedDB);"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import PouchDB from 'pouchdb';\n\nasync function initializeAndUseDB() {\n  // Open or create a database named 'my_local_db'\n  // In browsers, this defaults to IndexedDB. In Node.js, it uses LevelDB.\n  const db = new PouchDB('my_local_db');\n  console.log('Database opened successfully!');\n\n  try {\n    // Create a new document\n    const newDoc = {\n      _id: 'dave@example.com',\n      name: 'David Z.',\n      occupation: 'Developer',\n      age: 30\n    };\n    const response = await db.put(newDoc);\n    console.log('Document created:', response);\n\n    // Fetch the document\n    const fetchedDoc = await db.get('dave@example.com');\n    console.log('Document fetched:', fetchedDoc);\n\n    // Update the document\n    fetchedDoc.age = 31;\n    const updateResponse = await db.put(fetchedDoc);\n    console.log('Document updated:', updateResponse);\n\n    // Delete the database (for cleanup or testing)\n    // await db.destroy();\n    // console.log('Database destroyed.');\n\n  } catch (err) {\n    console.error('Error interacting with PouchDB:', err);\n  }\n}\n\ninitializeAndUseDB();","lang":"javascript","description":"Demonstrates how to install PouchDB, create a new local database, add, retrieve, and update documents using the async/await pattern.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}