Skip to content

Instantly share code, notes, and snippets.

@shipcake
Created July 9, 2019 13:22
Show Gist options
  • Save shipcake/cd2fc59486fd6e7f15d6a59072928a0b to your computer and use it in GitHub Desktop.
Save shipcake/cd2fc59486fd6e7f15d6a59072928a0b to your computer and use it in GitHub Desktop.
apollo schema
const { gql} = require('apollo-server-express')
const account = gql`
type token {
token:String,
date:String,
country:String,
city:String,
ip:String,
}
type member {
uid:String,
username:String,
password:String,
name:String,
lastname:String,
address:String,
phone:String,
mobile:String,
usertype:String,
create:String,
modifieddate:String,
token:[token]
}
type Account {
storeuid:String,
domain:String,
name:String,
lastname:String,
member:[member]
}
extend type Query {
show_token:[token]
}
`
module.exports = account
const { account } = require('../../../../mongo/model') //import categories mongo model
const show_token = async (_,req, ctx) => {
let Find = await account.findOne({ "_id": ctx.token.storeuid }).exec((err,doc)=> {
let Filter = doc.member.filter(e=>e.uid == ctx.token.uid)
let Get = Filter.map(e=>e.token)
console.log(Get)
return Get
})
return Find
}
module.exports = { show_token}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment