{"id":42522,"library":"cockpit-orm","title":"Cockpit ORM","description":"An object-relational mapping library for Cockpit Headless CMS (v0.4.0, stable). Provides Entry and Collection classes to manage Cockpit content without manually fetching the Cockpit API. Depends on cockpit-sdk ^0.8.3. Differentiates by offering a schema-driven, class-based ORM pattern similar to ActiveRecord, with features like slug-based syncing, save/update via POST, and custom collection methods. Useful for Node.js and browser environments.","status":"active","version":"0.4.0","language":"javascript","source_language":"en","source_url":"https://github.com/ginetta/cockpit-orm","tags":["javascript","cockpit","ORM","browser","headless"],"install":[{"cmd":"npm install cockpit-orm","lang":"bash","label":"npm"},{"cmd":"yarn add cockpit-orm","lang":"bash","label":"yarn"},{"cmd":"pnpm add cockpit-orm","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency required for API calls","package":"cockpit-sdk","optional":false}],"imports":[{"note":"Named export, not default","wrong":"import Entry from 'cockpit-orm'","symbol":"Entry","correct":"import { Entry } from 'cockpit-orm'"},{"note":"ESM only; named export","wrong":"const Collection = require('cockpit-orm').Collection","symbol":"Collection","correct":"import { Collection } from 'cockpit-orm'"},{"note":"Default export is undefined; use named exports only","wrong":"import cockpitOrm from 'cockpit-orm'","symbol":"default import","correct":"import { Entry, Collection } from 'cockpit-orm'"}],"quickstart":{"code":"import { Entry, Collection } from 'cockpit-orm';\nimport cockpit from 'cockpit-sdk';\n\nconst cockpitInstance = cockpit({\n  baseURL: 'https://your-cockpit.com/api',\n  token: process.env.COCKPIT_TOKEN ?? ''\n});\n\nclass Post extends Entry {\n  static cockpit = cockpitInstance;\n  static slugField = 'title_slug';\n  static schema = {\n    name: 'Posts',\n    fields: [\n      { name: 'title', type: 'text' },\n      { name: 'body', type: 'text' },\n      { name: 'published', type: 'boolean' }\n    ]\n  };\n}\n\nclass PostCollection extends Collection {\n  static collectionName = 'Posts';\n  static cockpit = cockpitInstance;\n}\n\nconst post = new Post();\npost.setSlug('my-first-post');\npost.sync().then(() => {\n  console.log(post.get('title'));\n});","lang":"javascript","description":"Shows how to extend Entry and Collection, sync an entry by slug, and get a field value."},"warnings":[{"fix":"Ensure the static schema matches the Cockpit collection schema verbatim, including field names and types.","message":"Joi validation error when schema does not match cockpit collection exactly","severity":"breaking","affected_versions":">=0.0.0"},{"fix":"Always sync() before reading fields, or check has() before get().","message":"Entry.get() returns undefined for fields not synced or set","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Use sync() to fetch existing data, modify, then save() to create a new version. There is no PUT/PATCH support.","message":"Entry.save() does not update existing entries; it always creates a new entry (POST)","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"N/A","message":"No deprecations noted in v0.4.0","severity":"deprecated","affected_versions":"0.4.0"}],"env_vars":null,"search_vec":"'0.8.3':35 'activerecord':50 'api':29 'base':45,56 'browser':69,74 'class':19,44 'class-bas':43 'cms':12 'cockpit':1,10,22,28,33,72 'cockpit-sdk':32 'collect':18,63 'content':23 'custom':62 'depend':30 'differenti':36 'driven':42 'entri':16 'environ':70 'featur':52 'fetch':26 'headless':11,75 'javascript':71 'librari':8 'like':53 'manag':21 'manual':25 'map':7 'method':64 'node.js':67 'object':5 'object-rel':4 'offer':38 'orm':2,46,73 'pattern':47 'post':60 'provid':15 'relat':6 'save/update':58 'schema':41 'schema-driven':40 'sdk':34 'similar':48 'slug':55 'slug-bas':54 'stabl':14 'sync':57 'use':65 'v0.4.0':13 'via':59 'without':24","created_at":"2026-06-05T16:55:23.755955+00:00","updated_at":"2026-06-05T16:55:23.755955+00:00","problems":[{"fix":"Replace 'import cockpitOrm from \"cockpit-orm\"' with 'import { Entry, Collection } from \"cockpit-orm\"'","cause":"Using default import when named exports are required","error":"TypeError: cockpit_orm__WEBPACK_IMPORTED_MODULE_0__ is undefined"},{"fix":"Add static schema = { name: 'YourCollectionName', fields: [...] } to the Entry subclass","cause":"Missing static schema.name or schema not provided","error":"Error: \"name\" is required"},{"fix":"Ensure sync() is called and awaited before get(), or use set() to set fields locally first","cause":"Trying to call get() on a non-synced Entry or without setting a slug/id","error":"Cannot read property 'get' of undefined"}],"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/ginetta/cockpit-orm#readme","github":"https://github.com/ginetta/cockpit-orm","docs":null,"changelog":null,"pypi":null,"npm":"cockpit-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-05","next_check":"2026-09-03","install_tag":null}}