I hereby claim:
- I am danielrearden on github.
- I am danielrearden (https://keybase.io/danielrearden) on keybase.
- I have a public key ASCcI8cGL1AfbfSgjEtpUtk5ELxgPuHf9mZqLdbEjz8EbQo
To claim this, I am signing this object:
const chance = require('chance') | |
module.exports = (db, table, specificProps) => db.raw(` | |
SELECT column_name, data_type | |
FROM information_schema.columns | |
WHERE table_name = '${table}'; | |
`).then((cols) => cols.reduce((memo, col) => { | |
switch (col.data_type) { | |
case 'uuid': return Object.assign({ [col.column_name]: chance.guid() }, memo); | |
case 'character varying': return Object.assign({ [col.column_name]: chance.word() }, memo); |
import crypto from 'crypto' | |
import redis from 'services/redis' | |
export async function queryWrapper (query, ttl) { | |
// these could also be passed explicitly to the function, but that may leave more room for error? | |
let table, method | |
query.modify(qb => { | |
table = qb._table || 'some_fallback' | |
method = qb._method | |
}) |
I hereby claim:
To claim this, I am signing this object:
type Customer @model( | |
table: "customers" | |
pk: "CustomerId" | |
) { | |
id: ID! @col(name: "CustomerId") | |
firstName: String! | |
lastName: String! | |
email: String! | |
} |
type Query @sqlmancer( | |
dialect: SQLITE | |
transformFieldNames: PASCAL_CASE | |
) { | |
customers: [Customer!]! | |
} |
type Customer @model( | |
table: "customers" | |
pk: "CustomerId" | |
) { | |
id: ID! @col(name: "CustomerId") | |
firstName: String! | |
lastName: String! | |
email: String! | |
invoices: [Invoice!]! | |
@relate(on: { from: "CustomerId", to: "CustomerId" }) |
type Query @sqlmancer( | |
dialect: POSTGRES | |
transformFieldNames: PASCAL_CASE | |
) { | |
customers: [Customer!]! @where @orderBy @limit @offset | |
invoices: [Invoice!]! @many | |
} |
invoices: [Invoice!]! | |
@relate(on: { from: "CustomerId", to: "CustomerId" }) | |
@many |
import Knex from "knex"; | |
const knex = Knex({ | |
client: "sqlite3", | |
connection: { | |
filename: "./sample.db" | |
} | |
}); |
import { createSqlmancerClient } from "sqlmancer"; | |
const client = createSqlmancerClient(__filename, knex); |