-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
34 lines (32 loc) · 874 Bytes
/
test.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
const MongoClient = require('mongodb').MongoClient;
require('dotenv').config();
const dbUrl = process.env.MONGOLAB_URI;
/*MongoClient.connect(dbUrl, (err, db) => {
if (err) console.log(err);
else {
db.db('lienet').collection('articles').find({}).sort({ id: -1 }).toArray((err, articles) => {
if (err) throw err;
else {
articles = [ articles[0] ];
articles.forEach(async (article) => {
let text = article.text || 'bibi';
let photoUrl = await Scarper.ScrapPhotoForArticle(text);
db
.db('lienet')
.collection('articles')
.updateOne({ id: article.id }, { $set: { photoUrl } }, (err, result) => {
if (err) throw err;
});
});
}
});
}
});*/
MongoClient.connect(dbUrl, (err, db) => {
if (err) console.log(err);
else {
db.db('lienet').collection('articles').deleteMany({
id: { $gt: 26 }
});
}
});