             else
                 cb2 new errors.NotFound("No such item")
         ], cb
-
-    ##
-    # @param itemCb {Function} itemCb({ node: String, id: String, item: Element })
-    getUpdatesByTime: (subscriber, timeStart, timeEnd, itemCb, cb) ->
-        conditions = [ "node IN (SELECT node FROM subscriptions WHERE \"user\"=$1 AND subscription='subscribed')" ]
-        params = [ subscriber ]
-        i = 1
-        if timeStart
-            conditions.push "updated >= $" + (++i) + "::timestamp"
-            params.push timeStart
-        if timeEnd
-            conditions.push "updated <= $" + (++i) + "::timestamp"
-            params.push timeEnd
-        q = @db.query("SELECT id, node, xml FROM items WHERE " + conditions.join(" AND ") + " ORDER BY updated ASC", params)
-        q.on "row", (row) ->
-            if item
-                itemCb
-                    node: row.node
-                    id: row.id
-                    item: row.xml
-
-
-        q.on "error", (err_) ->
-            err = err_
-
-        q.on "end", ->
-            cb err
 
     getRecentPosts: (subscriber, timeStart, maxItems, cb) ->
         db = @db

            nodes = res?.rows?.map (row) ->
                row.node
            cb null, nodes

exports.getListenerNodes = (listener, cb) ->
    db.query "SELECT DISTINCT node FROM subscriptions WHERE listener=$1", [listener], (err, res) ->
        cb err, res?.rows?.map (row) -> row.node


LOST_TRANSACTION_TIMEOUT = 60 * 1000


    withNextDb (db) ->
        new Transaction(db, cb)

exports.nodeExists = (node, cb) ->
    withNextDb (db) ->
        db.query "SELECT node FROM nodes WHERE node=$1", [ node ], (err, res) ->
