-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathworker.js
39 lines (28 loc) · 1.09 KB
/
worker.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
function initialImport(db, done) {
console.log("Initialize languages for hoodie-plugin-tarjomeh-languages")
var languages = ['persian', 'german', 'french', 'spanish', 'english'];
languages.forEach(function (language) {
db.add('language', {id: language, name: language}, function (error) {
if (error) return console.warn("Failed to add language", language, error)
});
});
done();
}
exports.dbName = 'hoodie-plugin-tarjomeh-languages';
module.exports = function (hoodie, done) {
hoodie.database.findAll(function (error, databases) {
if (error) return done(error);
if (databases.indexOf(exports.dbName) == -1) {
hoodie.database.add(exports.dbName, function (error, db) {
if (error) return done(error);
initialImport(db, function (error) {
if (error) return done(error);
db.grantPublicReadAccess(function (error) {
if (error) return done(error);
})
});
})
}
});
done();
};