npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@gavant/orbit-model

v0.0.9

Published

This package contains a wrapper layer which gives the ability to use models with orbit.js.

Downloads

4

Readme

orbit-model

This package contains a wrapper layer which gives the ability to use models with orbit.js.

Highlights

  • Access to the full power of Orbit and its ecosystem, including compatible sources, buckets, and coordination strategies.

  • A data schema that's declared through simple model definitions.

  • Stores that wrap Orbit sources and provide access to their underlying data as easy to use records and record arrays. These stores can be forked, edited in isolation, and merged back to the original as a coalesced changeset.

  • The full power of Orbit's composable query expressions.

  • The ability to connect any number of sources together with Orbit coordination strategies.

  • Orbit's git-like deterministic change tracking and history manipulation capabilities.

Relationship to Orbit

Orbit Model provides a thin layer over the top of some core primitives from Orbit, including Store, Cache, and Model classes. Most common developer interactions with Orbit will be through these classes.

Important: It's strongly recommended that you read the Orbit guides at orbitjs.com before using OrbitModel, since an understanding of Orbit is vital to making the most of OrbitModel.

Installation

Install OrbitModel in your project with:

yarn add @gavant/orbit-model

Defining models

Models are used to access the underlying data in an EO Store. They provide a proxy to get and set attributes and relationships. In addition, models are used to define the schema that's shared by the sources in your Orbit application.

The easiest way to create a Model class is with the data-model generator:

ember g data-model planet

This will create the following module in app/data-models/planet.js:

import { Model } from '@gavant/orbit-model';

export default class Planet extends Model {}

You can then extend your model to include keys, attributes, and relationships:

import { Model, attr, hasOne, hasMany, key } from '@gavant/orbit-model';

export default class Planet extends Model {
    @key() remoteId;
    @attr('string') name;
    @hasMany('moon', { inverse: 'planet' }) moons;
    @hasOne('star') sun;
}

You can create polymorphic relationships by passing in an array of types:

import { Model, attr, hasOne, hasMany } from '@gavant/orbit-model';

export default class PlanetarySystem extends Model {
    @attr('string') name;
    @hasMany(['moon', 'planet']) bodies;
    @hasOne(['star', 'binaryStar']) star;
}