Skip to content
This repository was archived by the owner on Nov 22, 2022. It is now read-only.

Repository files navigation

Spraypaint

JS Client for Graphiti similar to ActiveRecord.

Written in Typescript but works in plain old ES5 as well. This library is isomorphic - use it from the browser, or from the server with NodeJS.

Sample Usage

Please see our documentation page for full usage. Below is a Typescript sample:

import{SpraypaintBase,Model,Attr,HasMany}from"spraypaint"
@Model()classApplicationRecordextendsSpraypaintBase{staticbaseUrl="http://localhost:3000"staticapiNamespace="/api/v1"}
@Model()classPersonextendsApplicationRecord{staticjsonapiType="people"
@Attr()firstName: string
@Attr()lastName: string
@HasMany()pets: Pet[]getfullName(){return`${this.firstName}${this.lastName}`}}
@Model()classPetextendsApplicationRecord{staticjsonapiType="pets"
@Attr()name: string}let{ data }=awaitPerson.where({name: 'Joe'}).page(2).per(10).sort('name').includes("pets").all()letnames=data.map((p)=>{returnp.fullName})console.log(names)// ['Joe Blow', 'Joe DiMaggio', ...]console.log(data[0].pets[0].name)// "Fido"

About

Graphiti Client / Javascript ORM / JSONAPI

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages