Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ember-data/model

Package Overview
Dependencies
Maintainers
0
Versions
538
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ember-data/model

A basic Ember implementation of a resource presentation layer for use with @ember-data/store

  • 5.3.9
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
89K
increased by30.05%
Maintainers
0
Weekly downloads
 
Created
Source

EmberData Model EmberData Model

Runtime Classes for use as a Schema Source and Resource Presentation for EmberData

Installation

Install using your javascript package manager of choice. For instance with pnpm

pnpm add @ember-data/model

Tagged Releases

  • NPM Canary Version
  • NPM Beta Version
  • NPM Stable Version
  • NPM LTS Version
  • NPM LTS 4.12 Version

Provides a Presentation Model for resource data in an EmberData Cache

This package implements the EmberData Store's instantiateRecord and teardownRecord hooks as well as configures an associated SchemaService implementation.

Models are defined as classes extending from import Model from '@ember-data/model'; and the attributes and relationships on these classes are parsed at runtime to supply static "schema" to EmberData's SchemaService.

Resource data for individual resources fetched from your API is presented to the UI via instances of the Models you define. An instantiated Model is referred to as a record.

When we refer to the ModelClass as opposed to a Model or Record we are referring specifically to the class definition and the static schema methods present on it.

When we refer to a record we refer to a specific class instance presenting the resource data for a given type and id.

Defining a Model

app/models/person.js

import Model, { attr, belongsTo, hasMany } from '@ember-data/model';

export default class PersonModel extends Model {
  @attr name;

  @belongsTo('pet', { inverse: 'owners', async: false }) dog;

  @hasMany('person', { inverse: 'friends', async: true }) friends;
}

modelName convention

By convention, the name of a given model (its type) matches the name of the file in the app/models folder and should be lowercase, singular and dasherized.

Keywords

FAQs

Package last updated on 22 Oct 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc