{"library":"murmuration","title":"Murmuration","description":"Murmuration is a low-level database library providing statement generation, transactions, and migrations. It serves as a lightweight alternative to ORMs like Sequelize or TypeORM, focusing on minimal, dynamic query building with a promise-like syntax. The base package (v2.0.80) is abstract and intended to be extended by specific implementations: Murmuration-MariaDB and Murmuration-PostGreSQL. Key differentiators include its use of operations to wrap transactions and its built-in migration support that synchronizes the database schema during deployment. It deliberately avoids abstractions like models or query builders, giving developers direct control over SQL.","language":"javascript","status":"active","last_verified":"Sat May 09","install":{"commands":["npm install murmuration"],"cli":null},"imports":["const using = require('murmuration');","const { Statement } = require('murmuration');","const { migrate } = require('murmuration');"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"const { Statement, migrate } = require('murmuration');\nconst withConnection = (connection) => ({\n  selectFromUsers: () => ({\n    where: (conditions) => ({\n      one: (handler) => ({ else: (elseHandler) => ({ catch: (errHandler) => ({ execute: async () => {\n        const sql = `SELECT * FROM users WHERE ${Object.keys(conditions).map(k => `${k} = ?`).join(' AND ')}`;\n        const values = Object.values(conditions);\n        try {\n          const rows = await connection.execute(sql, values);\n          if (rows.length === 1) handler(rows[0]);\n          else elseHandler();\n        } catch (err) { errHandler(err); }\n      }})\n    })\n  })\n});\n\nconst using = (connection) => withConnection(connection);\n\nasync function quickstart() {\n  const connection = { execute: async (sql, params) => [[{ id: 1, name: 'Alice' }], []] };\n  const context = { emailAddress: 'alice@example.com', password: 'secret' };\n  using(connection)\n    .selectFromUsers()\n    .where({ emailAddress: context.emailAddress, password: context.password })\n    .one(({ id }) => { console.log('Found user:', id); })\n    .else(() => { console.log('User not found'); })\n    .catch((err) => { console.error('Error:', err); })\n    .execute();\n}\n\nquickstart();","lang":"javascript","description":"Demonstrates building a query dynamically with using(), where(), one(), else(), catch(), and execute().","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}