Mercurial > pumpbridge
view src/edgecontrol.coffee @ 0:b73191efc65b
Initial import of pumpbridge (bloody bloody alpha)
author | Mathias Gebbe <mgebbe@intevation.de> |
---|---|
date | Thu, 05 Jun 2014 10:35:15 +0200 |
parents | |
children | 98a070c98982 |
line wrap: on
line source
# Copyright (C) 2014 by Intevation GmbH # Author: Mathias Gebbe <mgebbe@intevation.de> # # This file is Free Software under the Apache License, Version 2.0 # (the "License"); and comes with ABSOLUTELY NO WARRANTY! # You may not use this file except in compliance with the License. # See LICENSE for details. async = require("async") _ = require("underscore") Edge = require("./edge") removeEdges = (userid, network, callback) -> delEdge = (edge, callback) -> unless edge.to.indexOf(network) is -1 edge.del callback return async.parallel [ (callback) -> return Edge.search( from: userid , (err, edges) -> if err callback err else async.each edges, delEdge, callback return ) (callback) -> return Edge.search( to: userid , (err, edges) -> if err callback err else async.each edges, delEdge, callback return ) ], callback return addEdge = (from, to) -> async.waterfall [(callback) -> Edge.create from: from to: to , callback return ], (err, result) -> return deleteEdge = (from, to) -> async.waterfall [(callback) -> bank = Edge.bank() bank.del Edge.type, Edge.key(from, to), callback return ], (err, result) -> return exports.removeEdges = removeEdges exports.deleteEdge = deleteEdge exports.addEdge = addEdge