Beispiel #1
0
def updateUser(req):
    result = client.command(
        "UPDATE "+ req["input"]["id"]+
        " SET name = " + "\""+req["input"]["name"]+"\""+ " RETURN AFTER "
        )
    for item in result:
            return json.dumps(item.__dict__)
Beispiel #2
0
def createRelationship(req):
    result = client.command("create edge relationships from " +
                            req["input"]["from"] + " TO " +
                            req["input"]["to"] + " SET relationship = " +
                            "\"" + req["input"]["relationship"] + "\"")
    for item in result:
        return json.dumps(item.__dict__)
Beispiel #3
0
def getUsers():
    result = client.command(
        "SELECT  FROM users"
        )
    response = []
    for item in result:
            response.append(json.dumps(item.__dict__))
    return response
Beispiel #4
0
def getUser(req):
    #return the content of input.id can be anything valid record
    result = client.command(
        "SELECT  FROM "+req["input"]["id"] 
        )
    response = []
    for item in result:
            response.append(json.dumps(item.__dict__))
    return response
Beispiel #5
0
def createUser(req):
    result = client.command(
        "INSERT INTO users"
        "(name)"
        "VALUES('%s')"
        % (
            req["input"]["name"]
        )
        )
    for item in result:
            return json.dumps(item.__dict__)
Beispiel #6
0
def createFile(req):
    file = req.files['file']
    mimetype = file.content_type
    filename = file.filename
    f = file.read()
    f = base64.b64encode(f).decode('ascii')
    result = client.command("INSERT INTO files"
                            "(binary,name,mimetype)"
                            "VALUES('%s','%s','%s')" % (
                                f,
                                filename,
                                mimetype,
                            ))
    resultArr = []
    for item in result:
        if "binary" in item.__dict__[
                "_OrientRecord__o_storage"]:  #delete the file from result to return to client
            del item.__dict__["_OrientRecord__o_storage"]["binary"]
        resultArr.append(item.__dict__)
    return json.dumps(resultArr)
Beispiel #7
0
def deleteUser(req):
    #delete the content of input.id can be anything valid vertex
    result = client.command(
        "DELETE vertex "
        + req["input"]["id"])
    return result