Skip to content

Instantly share code, notes, and snippets.

View jmn8718's full-sized avatar

Jose Miguel Navarro jmn8718

View GitHub Profile
{
"log": ["*"],
"CORS": {
"Origin": ["http://localhost:8000"],
"LoginOrigin": ["http://localhost:8000"],
"Headers": ["Content-Type"],
"MaxAge": 17280000
},
"databases": {
"db": {
@jmn8718
jmn8718 / my-sg-config-wh.json
Last active September 18, 2016 21:31
my-sg-config-wh.json
{
"interface": ":4984",
"adminInterface": ":4985",
"log": ["HTTP+"],
"databases": {
"db": {
"server": "http://couchbase-server:8091",
"bucket": "default",
"users": { "GUEST": {"disabled": false, "admin_channels": ["*"] } },
"event_handlers": {
type DeviceSubscription implements MetaSubscription{
type: String!
id: ID!
updatedAt: String!
name: String
currentLocation: Location
previousLocation: Location
}
subscription WatchDevices {
watchDevices {
type
id
name
updatedAt
currentLocation {
lat
lng
}
mutation CreateDevice($name: String! $location: LocationInput!){
createDevice(name:$name location: $location) {
id
name
location {
lat
lng
}
}
}
{
"watchDevices": {
"type": "CREATE_DEVICE",
"id": "593bc92ed26159038837bd5a",
"name": "test create subs",
"updatedAt": "Sat Jun 10 2017 10:25:50 GMT+0000 (UTC)",
"currentLocation": {
"lat": 65,
"lng": 46.3
},
{
"watchDevices": {
"type": "CREATE_DEVICE",
"id": "593bc92ed26159038837bd5a",
"name": "test create subs",
"updatedAt": "Sat Jun 10 2017 10:25:50 GMT+0000 (UTC)",
"currentLocation": {
"lat": 63,
"lng": 45.3
},
import { withFilter } from 'graphql-subscriptions';
...
Subscription: {
watchDevice: {
resolve: (payload) => payload,
subscribe: withFilter(
() => pubsub.asyncIterator(deviceConstants.UPDATE_DEVICE),
(payload, args) => payload._id.toString() === args.id,
@jmn8718
jmn8718 / models.json
Last active December 19, 2019 01:09
Models
// Tag Model
{
_id: mongo id,
label: string,
...
}
// Video Model
{
_id: mongo id,
@jmn8718
jmn8718 / query.js
Last active December 19, 2019 01:09
Mongo DB query
db.getCollection('playlists').aggregate([
{ $unwind: '$videos' },
{
$lookup: {
from: 'videos',
let: { videoId: '$videos' },
pipeline: [
{ $match: { $expr: { $and: [{ $eq: ['$_id', '$$videoId'] }] } } },
{
$lookup: {