GithubHelp home page GithubHelp logo

memoriam-tv / spraypaint.js Goto Github PK

View Code? Open in Web Editor NEW

This project forked from graphiti-api/spraypaint.js

0.0 1.0 0.0 847 KB

Graphiti Client / Javascript ORM / JSONAPI

License: MIT License

JavaScript 1.09% TypeScript 98.81% Shell 0.09%

spraypaint.js's Introduction

Spraypaint

A fork of the JS Client for Graphiti, made compatible with React-Native. This repository will be deleted if the compatibility-focused changes are merged into the main project.

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()
class ApplicationRecord extends SpraypaintBase {
  static baseUrl = "http://localhost:3000"
  static apiNamespace = "/api/v1"
}

@Model()
class Person extends ApplicationRecord {
  static jsonapiType = "people"

  @Attr() firstName: string
  @Attr() lastName: string

  @HasMany() pets: Pet[]

  get fullName() {
    return `${this.firstName} ${this.lastName}`
  }
}

@Model()
class Pet extends ApplicationRecord {
  static jsonapiType = "pets"

  @Attr() name: string
}

let { data } = await Person
  .where({ name: 'Joe' })
  .page(2).per(10)
  .sort('name')
  .includes("pets")
  .all()

let names = data.map((p) => { return p.fullName })
console.log(names) // ['Joe Blow', 'Joe DiMaggio', ...]

console.log(data[0].pets[0].name) // "Fido"

spraypaint.js's People

Contributors

wadetandy avatar richmolj avatar mqchau avatar jannishuebl avatar nobitagit avatar jimmy89 avatar eldub avatar gstark avatar cdidier80 avatar calebuharrison avatar yoann-hellopret avatar wkstar avatar japestrale avatar zpencerq avatar sherbrow avatar mkessler avatar e-pavlica avatar dishwasha avatar darronz avatar bilouw avatar zooip avatar reizar avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.