{"size": 768, "ext": "js", "max_stars_repo_path": "test/mongoUpdate/mongoInsert.js", "max_stars_repo_name": "katsuooo/mongoMemo", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "test/mongoUpdate/mongoInsert.js", "max_issues_repo_name": "katsuooo/mongoMemo", "max_issues_repo_issues_event_min_datetime": "2020-09-08T19:35:04.000Z", "max_issues_repo_issues_event_max_datetime": "2021-05-07T06:31:52.000Z", "max_forks_repo_path": "test/mongoUpdate/mongoInsert.js", "max_forks_repo_name": "katsuooo/mongoMemo", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": 2, "max_forks_count": null, "avg_line_length": 20.7567567568, "max_line_length": 80, "alphanum_fraction": 0.6692708333}
/*
 mongo upsert test
 mongodb version 3.1.0

 upsertテストのため、初期dbをつくる
*/


var mongodb = require('mongodb'), MongoClient = mongodb.MongoClient;
var fs = require('fs');
var CONFIG = require('../../config/config').CONFIG;

const MONGO_URL = CONFIG.mongodb.url + ':' + CONFIG.mongodb.port;
const dbName = CONFIG.mongodb.db;
const colName = 'upsertTest'

const myInfo = {name: 'katsuooo', age: '52'};

/*
 daily update
*/
async function genDb(){
    const client = await MongoClient.connect(MONGO_URL, {useNewUrlParser:true});
    const db = client.db(dbName);
    const collection = db.collection(colName);
    const d = await collection.insert(myInfo);
    client.close();
}


var mongoInsert = {
    genDb: () => {
        genDb();
    }
}

module.exports = mongoInsert;