{"library":"minato","title":"Minato Database Framework","description":"Minato is a type-driven database framework for JavaScript and TypeScript, designed to provide a unified API across various database backends. It supports a wide range of drivers including Memory, MongoDB, MySQL, PostgreSQL, and SQLite, allowing developers to switch databases with minimal code changes. Written entirely in TypeScript, Minato offers comprehensive type safety for schema definitions and queries, aiming to eliminate common database-related errors at compile time. It distinguishes itself by providing a powerful, extensible, and modern ORM experience that can handle complex SQL operations through a JavaScript API. Currently at version 4.0.1, Minato maintains an active, demand-driven release cadence, focusing on compatibility, performance, and a consistent developer experience across diverse data stores. Its tight integration capabilities with the Cordis framework make it particularly suitable for modular and extensible application architectures.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install minato"],"cli":null},"imports":["import Database from 'minato'","import MySQLDriver from '@minatojs/driver-mysql'","database.extend('collectionName', { /* schema */ })"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import Database from 'minato';\nimport MySQLDriver from '@minatojs/driver-mysql';\nimport type { Context } from 'cordis'; // Optional, if using Cordis\n\ninterface User {\n  id: number;\n  name: string;\n  age: number;\n  email?: string;\n}\n\nasync function runMinatoExample() {\n  // For Cordis integration, you might pass a Context, otherwise, it's optional.\n  // const ctx = new Context();\n  // const database = new Database(ctx); \n  const database = new Database();\n\n  // Define the schema for the 'user' collection/table\n  database.extend('user', {\n    id: 'unsigned', // Auto-incrementing primary key\n    name: 'string',\n    age: 'integer',\n    email: { type: 'string', nullable: true, unique: true },\n  }, {\n    primary: 'id',\n    autoInc: true,\n  });\n\n  // Connect to the database\n  try {\n    await database.connect(MySQLDriver, {\n      host: 'localhost',\n      port: 3306,\n      user: 'root',\n      password: process.env.DB_PASSWORD ?? '', // Use environment variable for sensitive info\n      database: 'minato_test_db',\n    });\n    console.log('Successfully connected to MySQL database.');\n\n    // Basic CRUD operations\n    // Create\n    const newUser = await database.create('user', {\n      name: 'Alice',\n      age: 30,\n      email: 'alice@example.com',\n    });\n    console.log('Created user:', newUser);\n\n    // Find\n    const users = await database.get('user', { age: { $gt: 25 } });\n    console.log('Users older than 25:', users);\n\n    // Update\n    await database.set('user', { id: newUser.id }, { age: 31 });\n    const updatedUser = await database.get('user', { id: newUser.id });\n    console.log('Updated user:', updatedUser[0]);\n\n    // Delete\n    await database.remove('user', { id: newUser.id });\n    console.log('Deleted user with ID:', newUser.id);\n\n  } catch (error) {\n    console.error('Database operation failed:', error);\n  } finally {\n    await database.disconnect();\n    console.log('Disconnected from database.');\n  }\n}\n\nrunMinatoExample();","lang":"typescript","description":"This quickstart demonstrates how to initialize Minato, define a type-safe schema, connect to a MySQL database using a separate driver, and perform common CRUD (Create, Read, Update, Delete) operations.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}