Graphql javascript model based - inspired by Laravel Eloquent
Graphql provide us very fast way to get data from backend. Laravel Eloquent provide model base working with database. The idea is provide a way to query data like Eloquent for javascript. And this package was born to provide fatest way to define model
- Postgresql
- Hasura or an api for backend
- Apollo client for graphql
- Static method of javascript from ECMAScript 2015
import Model from 'graphqloquent';
export default class Flight extends Model {
}
import Model from 'graphqloquent';
export default class Flight extends Model {
/**
* table: is the table associated with model
*/
constructor() {
this.table = 'my_flights';
}
}
import Model from 'graphqloquent';
export default class Flight extends Model {
/**
* key: is the table primary key
*/
constructor() {
this.key = 'my_flights_id';
}
}
By default, Graphloquent expects created_at and updated_at columns exist on your tables
import Model from 'graphqloquent';
export default class Flight extends Model {
/**
* key: is the table primary key
*/
constructor() {
this.key = 'my_flights_id';
}
}
import Flight from '@/models/Fligt';
$flights = Flight.all();
import Flight from '@/models/Flight';
$flight = Flight.where('active', 1)
.orderBy('name', 'desc')
.take(10)
.get();
import Flight from '@/models/Fligt';
$flight = Flight.find(1);
import Flight from '@/models/Flight';
$flight = Flight.where('active', 1).first();
import Flight from '@/models/Flight';
$flight = Flight.findOrFail(1);
$flight = Flight.where('leg', '>', 1).findOrFail();
import Flight from '@/models/Flight';
$flight = Flight.where('active', 1).count();
import Flight from '@/models/Flight';
$flight = new Flight();
$flight.name = 'Airbus 320';
$flight.save();
import Flight from '@/models/Flight';
$flight = Flight.find(1);
$flight.name = 'New Airbus 320';
$flight.save();
import Flight from '@/models/Flight';
$flight = Flight.find(1);
$flight.delete();