can-rest-model connects a CanJS DefineMap to a RESTful API endpoint. Version 2.0.0 provides a simple API to create model layers with automatic CRUD operations, serialization, and real-time support. It is part of the CanJS ecosystem and is maintained by Bitovi. Unlike generic REST clients, it integrates deeply with CanJS's observable maps and lists, enabling reactive data binding and seamless synchronization. Release cadence is sporadic; updates follow CanJS releases.
npm install can-rest-modelNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates defining a Todo model with DefineMap, connecting it to a REST API via restModel, and performing save and findAll operations.
Replace const restModel = require('can-rest-model') with import { restModel } from 'can-rest-model'.Import from 'can-connect' instead of 'can-connect/base'.
Ensure the DefineMap has { identity: true } on the primary key field.Use url: '/api/todos/{id}' with curly braces around the id placeholder.Provide a unique name (e.g., name: 'todo') for real-time support.
Use ES6 import: import { restModel } from 'can-rest-model'.Provide a url string with {id} placeholder, e.g., '/api/todos/{id}'.Add a property like id: {type: 'number', identity: true} to your DefineMap.Add name: 'todo' or similar to restModel options.