{"library":"lovefield","title":"Lovefield - Relational Database for Web Apps","description":"Lovefield is a relational database written entirely in JavaScript, designed for web applications. It provides a SQL-like query API, leveraging IndexedDB for persistent storage in the browser environment. Developed by Google, the package reached its last published version, 2.1.12, in February 2017. While the GitHub repository saw minor updates until January 2023, active feature development and official maintenance appear to have ceased significantly earlier, around 2015-2017, as indicated by project videos and publishing dates. Lovefield offers cross-browser compatibility (supporting older versions of Chrome, Firefox, IE, and Safari) but explicitly does not support Node.js due to its reliance on IndexedDB. Its key differentiators were bringing a relational model and SQL-like syntax to client-side data management before more modern alternatives emerged, offering atomic transactions and a query optimizer.","language":"javascript","status":"abandoned","last_verified":"Wed Apr 22","install":{"commands":["npm install lovefield"],"cli":null},"imports":["<!-- In HTML -->\n<script src=\"path/to/lovefield.min.js\"></script>\n<script>\n  const schemaBuilder = lf.schema.create('my_db', 1);\n  // ... rest of your code using lf\n</script>","const schemaBuilder = lf.schema.create('my_db', 1);","addColumn('id', lf.Type.INTEGER);"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"<!-- In an HTML file -->\n<!doctype html>\n<html>\n<head>\n  <meta charset=\"utf-8\" />\n  <title>Lovefield Quick Start</title>\n  <script src=\"https://unpkg.com/lovefield@2.1.12/dist/lovefield.min.js\"></script>\n</head>\n<body>\n  <script>\n    // Define the database schema\n    const schemaBuilder = lf.schema.create('todoDb', 1);\n    schemaBuilder.createTable('Item')\n        .addColumn('id', lf.Type.INTEGER)\n        .addColumn('description', lf.Type.STRING)\n        .addColumn('deadline', lf.Type.DATE_TIME)\n        .addColumn('done', lf.Type.BOOLEAN)\n        .addPrimaryKey(['id'])\n        .addIndex('idxDeadline', ['deadline'], false, lf.Order.DESC);\n\n    let todoDb;\n    let itemTable;\n\n    // Connect to the database and perform operations\n    schemaBuilder.connect().then(function(db) {\n      todoDb = db;\n      itemTable = db.getSchema().table('Item');\n\n      // Create a new row\n      const row = itemTable.createRow({\n        'id': 1,\n        'description': 'Buy groceries',\n        'deadline': new Date(2026, 4, 25),\n        'done': false\n      });\n\n      // Insert the row into the database\n      return db.insertOrReplace().into(itemTable).values([row]).exec();\n    }).then(function() {\n      // Query data\n      return todoDb.select().from(itemTable).where(itemTable.done.eq(false)).exec();\n    }).then(function(results) {\n      // Process results\n      results.forEach(function(row) {\n        console.log(`Task: ${row['description']}, Due: ${row['deadline'].toLocaleDateString()}`);\n      });\n\n      // Example: Update an item\n      return todoDb.update(itemTable)\n                   .set(itemTable.done, true)\n                   .where(itemTable.id.eq(1))\n                   .exec();\n    }).then(() => {\n      console.log('Task ID 1 marked as done.');\n    }).catch(err => {\n      console.error('Lovefield operation failed:', err);\n    });\n  </script>\n</body>\n</html>","lang":"javascript","description":"This quickstart demonstrates how to define a database schema, connect to the database, insert data, and query data using Lovefield's SQL-like API in a browser environment, including a simple update operation.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}