The last modifications of this post were around 2 years ago, some information may be outdated!
This is a draft, the content is not complete and of poor quality!
RunJS is a wonderful playground application for testing quickly JavaScript and NodeJS.
MongoDB
Setting up the environement variables first.
async function initMongoDb() {
const uri = `mongodb+srv://${process.env.IDETA_MONGO_USER}:${process.env.IDETA_MONGO_PASSWORD}@${process.env.IDETA_MONGO_HOST}`;
console.log(uri);
try {
const client = await MongoClient.connect(uri, {
useUnifiedTopology: true
});
return { client, db: client.db(`${process.env.IDETA_MONGO_DATABASE}`) };
} catch (e) {
throw e;
}
}
async function testMongo() {
const mongo = await initMongoDb();
return mongo.db.collection('agents').findOne({ active: false });
}
async function main() {
const agent = await testMongo();
console.log(agent);
}
main();
Lodash
👉 Lodash doc.
var _ = require('lodash');
// and then test with snippets on the doc
_.chunk(['a', 'b', 'c', 'd'], 2);
💬 Comments