{"id":41059,"library":"expo-sqlite-eloquent-orm","title":"Expo SQLite Eloquent ORM","description":"Expo SQLite Eloquent ORM v0.10.6 is a lightweight, fluent ORM wrapper for expo-sqlite in React Native/Expo apps, inspired by Laravel's Eloquent. It provides a query builder, model-based CRUD, relationships, attribute casting, and a migration system. Updated regularly on npm, it competes with other SQLite wrappers by offering a Laravel-like API. Released under MIT license, it requires expo-sqlite ~13.4.0, React ^18.2.0, and React Native ^0.73.2.","status":"active","version":"0.10.6","language":"javascript","source_language":"en","source_url":"https://github.com/theianjohnson/expo-sqlite-eloquent-orm","tags":["javascript","expo","sqlite","orm","database","eloquent","typescript"],"install":[{"cmd":"npm install expo-sqlite-eloquent-orm","lang":"bash","label":"npm"},{"cmd":"yarn add expo-sqlite-eloquent-orm","lang":"bash","label":"yarn"},{"cmd":"pnpm add expo-sqlite-eloquent-orm","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required peer dependency for SQLite database access in Expo/React Native.","package":"expo-sqlite","optional":false},{"reason":"Required peer dependency for React Native environment.","package":"react","optional":false},{"reason":"Required peer dependency for React Native environment.","package":"react-native","optional":false}],"imports":[{"note":"The library is ESM-first and ships TypeScript types. Named export.","wrong":"const { Model } = require('expo-sqlite-eloquent-orm')","symbol":"Model","correct":"import { Model } from 'expo-sqlite-eloquent-orm'"},{"note":"Casts is a TypeScript type, not a runtime value. Use import type for type-only imports.","wrong":"import { Casts } from 'expo-sqlite-eloquent-orm'","symbol":"Casts","correct":"import type { Casts } from 'expo-sqlite-eloquent-orm'"},{"note":"ModelAttributes is a TypeScript type interface.","wrong":"import { ModelAttributes } from 'expo-sqlite-eloquent-orm'","symbol":"ModelAttributes","correct":"import type { ModelAttributes } from 'expo-sqlite-eloquent-orm'"}],"quickstart":{"code":"import { Model } from 'expo-sqlite-eloquent-orm';\n\nclass User extends Model {\n  static tableName = 'users';\n  casts = {\n    is_admin: 'boolean',\n    metadata: 'json',\n  };\n}\n\nasync function example() {\n  // Create the users table\n  await User.executeSql(\n    `CREATE TABLE IF NOT EXISTS users (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, email TEXT, is_admin INTEGER DEFAULT 0, metadata TEXT DEFAULT '{}')`,\n    []\n  );\n\n  // Insert a new user\n  await User.insert({ name: 'Alice', email: 'alice@example.com', is_admin: true, metadata: { theme: 'dark' } });\n\n  // Find user by id\n  const user = await User.find(1);\n  console.log(user?.name); // Alice\n  console.log(user?.is_admin); // true (cast from integer)\n  console.log(user?.metadata); // { theme: 'dark' } (cast from JSON string)\n\n  // Update user\n  if (user) {\n    await user.update({ name: 'Alice Smith' });\n  }\n\n  // Query with where\n  const admins = await User.where('is_admin', 1).get();\n  console.log(admins.length);\n}\n\nexample();","lang":"typescript","description":"Defines a User model with attribute casting, creates table, inserts, finds, updates, and queries records using the ORM."},"warnings":[{"fix":"Define a static `tableName` property in your model class instead of calling `Model.table('name')`.","message":"In version 0.5.0, the `table` static method was removed in favor of a `tableName` static property on Model subclasses.","severity":"breaking","affected_versions":"<0.5.0"},{"fix":"Use methods like `insert`, `where`, `get` for common operations.","message":"The `executeSql` static method is intended for raw SQL; prefer the query builder for most operations.","severity":"deprecated","affected_versions":">=0.1.0"},{"fix":"Define `casts` as an object in the class instance, e.g., `casts = { age: 'number', is_active: 'boolean' }`.","message":"The `casts` property must be defined as an instance property (not static) and specified as `'number' | 'boolean' | 'string' | 'json'` strings. Incorrect casting types can cause runtime errors.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Call `user.hasMany(Post)` on an instance, not `User.hasMany(Post)`.","message":"Relations (`hasOne`, `hasMany`, `belongsTo`, `belongsToMany`) are instance methods and must be called on a model instance, not statically.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Check for `null` explicitly, e.g., `const user = await User.find(1); if (user !== null) { ... }`.","message":"The `find` method returns `null` when no record is found, not `undefined`.","severity":"gotcha","affected_versions":">=0.1.0"}],"env_vars":null,"search_vec":"'0.73.2':77 '13.4.0':71 '18.2.0':73 'api':61 'app':23 'attribut':39 'base':36 'builder':33 'cast':40 'compet':50 'crud':37 'databas':82 'eloqu':3,7,28,83 'expo':1,5,18,69,79 'expo-sqlit':17,68 'fluent':13 'inspir':24 'javascript':78 'laravel':26,59 'laravel-lik':58 'licens':65 'lightweight':12 'like':60 'migrat':43 'mit':64 'model':35 'model-bas':34 'nativ':76 'native/expo':22 'npm':48 'offer':56 'orm':4,8,14,81 'provid':30 'queri':32 'react':21,72,75 'regular':46 'relationship':38 'releas':62 'requir':67 'sqlite':2,6,19,53,70,80 'system':44 'typescript':84 'updat':45 'v0.10.6':9 'wrapper':15,54","created_at":"2026-06-04T18:50:34.354485+00:00","updated_at":"2026-06-04T18:50:34.354485+00:00","problems":[{"fix":"Add `static tableName = 'your_table';` to your model class.","cause":"Model subclass does not define a static `tableName` property.","error":"TypeError: Cannot read properties of undefined (reading 'tableName')"},{"fix":"Ensure cast type strings are exactly one of: 'number', 'boolean', 'string', 'json'.","cause":"The `casts` property uses an incorrect type string (e.g., 'number' instead of 'number').","error":"Error: Invalid cast type: 'number'"},{"fix":"Always define a table name via `static tableName` in your model or use `User.table('users')` before `get()`.","cause":"Calling `get()` without first setting a table or query (e.g., missing `static tableName` or `where` clause).","error":"Error: get() method called without defining table or query"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/theianjohnson/expo-sqlite-eloquent-orm#readme","github":"https://github.com/theianjohnson/expo-sqlite-eloquent-orm","docs":null,"changelog":null,"pypi":null,"npm":"expo-sqlite-eloquent-orm","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-04","next_check":"2026-09-02","install_tag":null}}