This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exports.seed = function (knex) { | |
// Deletes ALL existing entries | |
return knex("table name") | |
.del() | |
.then(function () { | |
// Inserts seed entries | |
return knex("table name").insert([ | |
// here will be your data with the fields your database needs | |
// for example { id: 1, full_name: "luis", country_code: 58 }, | |
, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exports.seed = function (knex) { | |
// Deletes ALL existing entries | |
return knex("users") | |
.del() | |
.then(function () { | |
// Inserts seed entries | |
return knex("users").insert([ | |
{ id: 1, full_name: "luis", country_code: 58 }, | |
{ id: 2, full_name: "jose", country_code: 59 }, | |
{ id: 3, full_name: "raul", country_code: 39 }, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {Pet,User} from '../../database/models'; | |
import {Resolvers} from '../../__generated__/generated-types'; | |
import {UserInputError} from 'apollo-server-express'; | |
const resolvers : Resolvers = { | |
Query:{ | |
pet:async (parent,args,ctx)=>{ | |
const pet:Pet= await Pet.query().findById(args.id); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const default_config = { | |
client: 'pg', | |
connection: { | |
database: "db", | |
user: "user", | |
password: "password" | |
}, | |
pool: { | |
min: 2, | |
max: 10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {Pet,User} from '../../database/models'; | |
import {Resolvers} from '../../__generated__/generated-types'; | |
import {UserInputError} from 'apollo-server-express'; | |
const resolvers : Resolvers = { | |
Query:{ | |
pet:async (parent,args,ctx)=>{ | |
const pet:Pet= await Pet.query().findById(args.id); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum Species{ | |
BIRDS, | |
FISH, | |
MAMMALS, | |
REPTILES | |
} | |
type User { | |
id: Int! | |
full_name: String |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {Model} from 'objection'; | |
import {Species,Maybe} from '../../__generated__/generated-types'; | |
import User from './User'; | |
class Pet extends Model{ | |
static tableName = "pets"; | |
id! : number; | |
name?: Maybe<string>; | |
specie?: Maybe<Species>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require('ts-node/register'); | |
module.exports = { | |
development:{ | |
client: 'pg', | |
connection: { | |
database: "my_db", | |
user: "username", | |
password: "password" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as Knex from "knex"; | |
export async function up(knex: Knex): Promise<any> { | |
return knex.schema.createTable('users',(table:Knex.CreateTableBuilder)=>{ | |
table.increments('id'); | |
table.string('full_name',36); | |
table.integer('country_code'); | |
table.timestamps(true,true); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
{ | |
"compilerOptions": { | |
"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */ | |
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */ | |
/* Concatenate and emit output to single file. */ | |
"outDir": "dist", /* Redirect output structure to the directory. */ | |
"rootDir": "src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ | |
"strict": true, /* Enable all strict type-checking options. */ | |
NewerOlder