This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const objectToCsv = function(data){ | |
const csvRows =[]; | |
//get the headers | |
const headers = Object.keys(data[0]); | |
csvRows.push(headers.join(',')); | |
//loop over the rows | |
for (const row of data){ | |
const values = headers.map(header =>{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const download = function(data){ | |
const blob = new Blob([data], {type : 'text/csv'}); | |
const url = window.URL.createObjectURL(blob); | |
const a = document.createElement('a'); | |
a.setAttribute('hidden', ''); | |
a.setAttribute('href', url); | |
a.setAttribute('download', 'download.csv'); | |
document.body.appendChild(a); | |
a.click(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
db.getCollection('tests').aggregate([ | |
{$match: {typet:'Req'}}, | |
{$set: {incharge: {$toObjectId: "$incharge"} }}, // keep the whole document structure, but replace `incharge` into ObjectId | |
{$lookup:{ | |
from: "users", | |
localField: "incharge", //this is the _id user from tests | |
foreignField: "_id", //this is the _id from users | |
as: "user" | |
}} | |
]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
isEqual = (a, b, options)=>{ | |
if(a == b){ | |
return options.fn(this) | |
} | |
return options.inverse(this) | |
} |