overleaf/services/spelling/app/coffee/LearnedWordsManager.coffee

19 lines
476 B
CoffeeScript
Raw Normal View History

2014-08-15 07:13:35 -04:00
db = require("./DB")
module.exports = LearnedWordsManager =
learnWord: (user_token, word, callback = (error)->) ->
db.spellingPreferences.update {
token: user_token
}, {
$push: learnedWords: word
}, {
upsert: true
}, callback
getLearnedWords: (user_token, callback = (error, words)->) ->
db.spellingPreferences.findOne token: user_token, (error, preferences) ->
return callback error if error?
callback null, (preferences?.learnedWords || [])