dbcopycat
Version:
A JSON Database that saves your Json data in a file and makes it easy for you to perform CRUD operations.
13 lines (11 loc) • 374 B
JavaScript
const getAll = require("./getAll");
const log = require('../utils/log');
function getById(arrayName, dataId) {
var dataAll = getAll();
if (dataAll[arrayName] == undefined) {
log(`${arrayName} array not found.`, "Error", "error");
return undefined
}
return dataAll[arrayName].find(x => x.id == dataId)
}
module.exports = getById;