{"id":44035,"library":"theorm","title":"theorm","description":"theorm is a Node.js MySQL ORM that provides a simple, model-based approach to interacting with MySQL databases. The current stable version is 0.2.13, released as a work-in-progress. It supports a variety of primitive property types (bool, int, char, etc.) with automatic column type mapping and indexing options. Unlike larger ORMs like Sequelize or TypeORM, theorm is lightweight and focuses on MySQL only, with no dependency on TypeScript. It offers built-in search mapping and auto-increment primary key types. The library is still early stage, with limited documentation and community support.","status":"active","version":"0.2.13","language":"javascript","source_language":"en","source_url":"https://github.com/numinos1/theorm","tags":["javascript","database","orm","sql","relational","query","caching"],"install":[{"cmd":"npm install theorm","lang":"bash","label":"npm"},{"cmd":"yarn add theorm","lang":"bash","label":"yarn"},{"cmd":"pnpm add theorm","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"MySQL database driver required for database operations.","package":"mysql2","optional":false}],"imports":[{"note":"theorm supports both ESM and CommonJS. Use named import for ESM.","wrong":"const { Model } = require('theorm');","symbol":"Model","correct":"import { Model } from 'theorm'"},{"note":"type is a named export containing all primitive type definitions.","wrong":"const type = require('theorm').type;","symbol":"type","correct":"import { type } from 'theorm'"},{"note":"Function to establish a MySQL connection. Required before using models.","symbol":"connect","correct":"import { connect } from 'theorm'"},{"note":"db is a utility object for raw queries or transaction management.","symbol":"db","correct":"import { db } from 'theorm'"}],"quickstart":{"code":"import { Model, type, connect } from 'theorm';\n\nconst dbConfig = {\n  host: process.env.MYSQL_HOST ?? 'localhost',\n  user: process.env.MYSQL_USER ?? 'root',\n  password: process.env.MYSQL_PASSWORD ?? '',\n  database: process.env.MYSQL_DATABASE ?? 'test'\n};\n\nawait connect(dbConfig);\n\nclass User extends Model {\n  static tableName = 'users';\n  static fields() {\n    return {\n      id: type.primary_key(),\n      name: type.varchar({ size: 100 }),\n      email: type.varchar({ size: 255, index: true }),\n      age: type.int({ allow_null: true }),\n      active: type.bool_true()\n    };\n  }\n}\n\nconst user = new User();\nuser.name = 'John';\nuser.email = 'john@example.com';\nuser.age = 30;\nawait user.save();\nconsole.log('User saved with id:', user.id);\n\nconst foundUser = await User.find(1);\nconsole.log(foundUser.name);\n\nconst users = await User.where({ active: true });\nconsole.log(users.length);","lang":"typescript","description":"Shows how to define a model with various property types, create a record, and query using primary key find and where clause."},"warnings":[{"fix":"Define 'static fields()' in the class instead of a regular method.","message":"Model.fields() must be a static method returning an object; using instance method will cause undefined behavior.","severity":"breaking","affected_versions":">=0.1.0"},{"fix":"Call await connect(config) at application startup.","message":"The 'connect' function must be called before any model operations; otherwise operations throw an error.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Explicitly set default_value or use specific type variants.","message":"Default values for boolean fields: type.bool_true() defaults to true, type.bool_false() defaults to false, but type.bool() defaults to 0 (false).","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Avoid using string_key; use separate primary key with char instead.","message":"The 'string_key' option in char types is deprecated and may be removed in future versions.","severity":"deprecated","affected_versions":">=0.2.0"}],"env_vars":null,"search_vec":"'0.2.13':26 'approach':15 'auto':83 'auto-incr':82 'automat':47 'base':14 'bool':42 'built':77 'built-in':76 'cach':106 'char':44 'column':48 'communiti':98 'current':22 'databas':20,101 'depend':71 'document':96 'earli':92 'etc':45 'focus':65 'increment':84 'index':52 'int':43 'interact':17 'javascript':100 'key':86 'larger':55 'librari':89 'lightweight':63 'like':57 'limit':95 'map':50,80 'model':13 'model-bas':12 'mysql':6,19,67 'node.js':5 'offer':75 'option':53 'orm':7,56,102 'primari':85 'primit':39 'progress':33 'properti':40 'provid':9 'queri':105 'relat':104 'releas':27 'search':79 'sequel':58 'simpl':11 'sql':103 'stabl':23 'stage':93 'still':91 'support':35,99 'theorm':1,2,61 'type':41,49,87 'typeorm':60 'typescript':73 'unlik':54 'varieti':37 'version':24 'work':31 'work-in-progress':30","created_at":"2026-06-05T17:02:39.988476+00:00","updated_at":"2026-06-05T17:02:39.988476+00:00","problems":[{"fix":"Ensure class extends Model and call connect() before any find operation.","cause":"Model class not properly defined or static methods not available due to incorrect inheritance.","error":"TypeError: Model.find is not a function"},{"fix":"Add await connect(config) at the beginning of your application.","cause":"Attempted to use model before calling connect().","error":"Error: Connection not established. Call connect() first."},{"fix":"Use import { type } from 'theorm' or const { type } = require('theorm').","cause":"Importing incorrectly; type is a named export.","error":"TypeError: Cannot read properties of undefined (reading 'type')"}],"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/numinos1/theorm","github":"https://github.com/numinos1/theorm","docs":null,"changelog":null,"pypi":null,"npm":"theorm","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-05","next_check":"2026-09-03","install_tag":null}}