mock-cloud-firestore
Version:
Mock library for Cloud Firestore
18 lines (14 loc) • 424 B
JavaScript
/* eslint no-param-reassign: 'off' */
export default function getOrSetDataNode(data, path, id) {
if (!Object.prototype.hasOwnProperty.call(data, path)) {
data[path] = {};
}
if (!Object.prototype.hasOwnProperty.call(data[path], id)) {
if (path === '__collection__') {
data[path][id] = {};
} else {
data[path][id] = { __isDirty__: true };
}
}
return data[path][id];
}