Skip to content

Instantly share code, notes, and snippets.

Avatar

Rubycut rubycut

View GitHub Profile
View basicModel.ts
import { Document, Schema, Model, model, Types } from "mongoose"
// We are definining typescript basic typescript interface first, properties only
export interface IHouse {
id?: any
name: string
rooms: Types.DocumentArray<IRoomDocument>
owners: Types.DocumentArray<IOwnerDocument>
}
View p-limit.js
import pLimit from "p-limit"
import PromiseBar from "promise.bar"
PromiseBar.enable()
// set concurrency
const limit = pLimit(5)
// create array which we will use to throttle requests
const requests = []
View index.js
Promise.all(my_array.map(async (myObject) => {
await myObject.httpPost()
}
View resolver2.js
import {Cluster} from './cluster.js'
const graphqlFields = require('graphql-fields');
import * as _ from 'lodash'
const resolvers = {
Query: {
customer(root, args, context,info) {
var requested_fields = Object.keys(graphqlFields(info))
var c = Cluster.findForUser(context,args.id)
@rubycut
rubycut / resolver.js
Last active Oct 8, 2017
graphql article
View resolver.js
const resolvers = {
Query: {
customer(root, args, context,info) {
var c = Customer.findForUser(context,args.id).populate('contacts')
}
}
}