Skip to content

Commit bb88788

Browse files
flipsideaseemk
authored andcommitted
added unindex function for nodes
1 parent da0f986 commit bb88788

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

lib/Node._coffee

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,40 @@ module.exports = class Node extends PropertyContainer
160160

161161
catch error
162162
throw adjustError error
163+
#
164+
# Delete this node from the given index.
165+
#
166+
# @param index {String} The name of the index, e.g. `'users'`.
167+
# @param callback {Function}
168+
#
169+
unindex: (index, _) ->
170+
try
171+
# TODO
172+
if not @exists
173+
throw new Error 'Node must exists before unindexing properties'
174+
175+
services = @db.getServices _
176+
# version = @db.getVersion _
177+
178+
# encodedKey = encodeURIComponent key
179+
# encodedValue = encodeURIComponent value
180+
url = "#{services.node_index}/#{index}/#{@id}"
181+
182+
response = @_request.delete
183+
url: url
184+
json: @self
185+
, _
186+
187+
188+
if response.statusCode isnt status.NO_CONTENT
189+
# database error
190+
throw response
191+
192+
# success
193+
return
194+
195+
catch error
196+
throw adjustError error
163197

164198
#
165199
# Uniquely add this node to the given index under the given key-value pair.

0 commit comments

Comments
 (0)