Models

AJAX Abstraction for a Single Resource

extend

The extend() method is used when you want to create a new Model that inherits the properties and methods of the previous one.

Usage

This method is used to create new Models like this:

import { Model } from 'lore-models';

const model = new Model();

const Tweet = Tweet.extend({
  cidPrefix: 'm',
  urlRoot: 'http://localhost:1337/tweets'
})

const tweet = new Tweet();

const User = Tweet.extend({
  urlRoot: 'http://localhost:1337/users'
})

const user = new User();

In the code above, we've created three models; model, tweet, and user.

The model will inherit the behavior of Model, and will have a cid of c1, and a urlRoot of ''.

The tweet will inherit the behavior of Tweet, which overrides some of the properties of Model, and will have a cid of m2, and a urlRoot of http://localhost:1337/tweets.

The user will inherit the behavior of User, which overrides some of the properties of Tweet, and will have a cid of m3, and a urlRoot of http://localhost:1337/users.