Skip to content

Instantly share code, notes, and snippets.

View MichelDiz's full-sized avatar
🎼
If I die before I wake, pray the lord my soul to take.

Michel Diz MichelDiz

🎼
If I die before I wake, pray the lord my soul to take.
View GitHub Profile

Keybase proof

I hereby claim:

  • I am micheldiz on github.
  • I am micheldiz (https://keybase.io/micheldiz) on keybase.
  • I have a public key ASBjU3iHeA4_FpHGHorzXcFzmx9aExSv93oxLkvXVqg4MQo

To claim this, I am signing this object:

@MichelDiz
MichelDiz / sql.js
Last active November 20, 2017 14:56
This is an example code of how the apollo-universal-starter-kit would work using Dgraph. A powerful graph database, fast, has clustering ability, created in GoLang and so on. In this example I'm using a client that uses gRPC to communicate with Dgraph. See docs https://docs.dgraph.io/
// Helpers
//import { camelizeKeys, decamelizeKeys, decamelize } from 'humps';
import { has } from 'lodash';
import bcrypt from 'bcryptjs';
import DgraphClient from 'dgraph-node';
// Create a new client
let client = new DgraphClient({
url: 'localhost:9080',
debug: false
async registerDgraph({ username, email, password, role, isActive }) {
// const passwordHashed = await bcrypt.hash(password, 12);
console.log(username, '<====== username');
const txn = dgraph.newTxn();
try {
if (role === undefined) {
role = 'user';
}
const now = new Date().toISOString();
let mu = new dgraph.Mutation();
{
"set": [ {
"user": [
{
"uid": "_:michael",
"name": "Michael",
"age": 39,
"Posts": [
{
"uid": "_:michaelfirst",
{
GetIssues_Customer_By_metaTags(func: eq(title, "Hyper Tech")) # @cascade @normalize
{
uid
issues @filter(eq(metaTags, ["Urgent","Bug"]))# AND NOT eq(metaCategories, "Problem"))
{
title
metaTags
metaCategories
participants {
@MichelDiz
MichelDiz / dgraph-1.1.0-rc3-test.go
Last active August 29, 2019 01:08 — forked from bgv/dgraph-1.1.0-rc3-test.go
dgraph-1.1.0-rc3-test.go
package main
import (
"context"
"encoding/json"
"fmt"
"log"
"github.com/dgraph-io/dgo/v2"
"github.com/dgraph-io/dgo/v2/protos/api"
package main
import (
"context"
"encoding/json"
"fmt"
"log"
"github.com/dgraph-io/dgo/v2"
"github.com/dgraph-io/dgo/v2/protos/api"
upsert {
query {
getVals(func: has(products)) {
productsUid as uid
products @filter(eq(productId, 19610626)) {
productUid as uid
options @filter(eq(optionId, 32661491)) {
optionUid as uid
}
}
// To parse this JSON data, do
//
// final stateResponse = stateResponseFromJson(jsonString);
import 'dart:convert';
StateResponse stateResponseFromJson(String str) => StateResponse.fromJson(json.decode(str));
String stateResponseToJson(StateResponse data) => json.encode(data.toJson());
type Team {
name: string
}
type Player {
name: string
Seasons: [uid]
}
type Season {