Skip to content

Commit

Permalink
Added update, remove to the API, some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Crenshinibon committed Sep 24, 2013
1 parent bd5cae2 commit ad75f75
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
Binary file added .DS_Store
Binary file not shown.
8 changes: 8 additions & 0 deletions packages/spomet/client.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ Spomet.clearSearch = () ->
Spomet.add = (findable) ->
Meteor.call 'spometAdd', findable, () ->
Spomet.clearSearch()

Spomet.update = (findable) ->
Meteor.call 'spometUpdate', findable, () ->
Spomet.clearSearch()

Spomet.remove = (findable) ->
Meteor.call 'spometRemove', findable, () ->
Spomet.clearSearch()

Spomet.setSort = (sort) ->
Session.set 'spomet-search-sort', sort
Expand Down
6 changes: 6 additions & 0 deletions packages/spomet/server.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ Meteor.methods
Spomet.find phrase
spometAdd: (findable) ->
Spomet.add findable
spometRemove: (findable) ->
Spomet.remove findable.docId
spometUpdate: (findale) ->
prevDocId = findable.previousVersionDocId()
Spomet.remove prevDocId
Spomet.add findable

Meteor.publish 'documents', () ->
Spomet.Documents.collection.find {},
Expand Down
9 changes: 5 additions & 4 deletions packages/spomet/shared.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,11 @@ Spomet.buildSearchQuery = (phrase, sort, offset, limit) ->
[selector, opts]

class Spomet.Findable
version: 1
type: 'default'
constructor: (@text, @path, @base, @type, @version) ->
@docId = type + '-' + base + '-' + path + '-' + version

unless version? then @version = 1
unless type? then @type = 'default'
@docId = @type + '-' + base + '-' + path + '-' + @version
previousVersionDocId: () ->
@type + '-' + @base + '-' + @path + '-' + (@version - 1)

@Index = {}

0 comments on commit ad75f75

Please sign in to comment.