mirror of
https://github.com/overleaf/overleaf.git
synced 2024-10-31 21:21:03 -04:00
19 lines
476 B
CoffeeScript
19 lines
476 B
CoffeeScript
|
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 || [])
|
||
|
|
||
|
|