export default async function editLocation(db, id, data) {
  const output = { ...data, updatedAt: new Date() };
  if (data.jobId) {
    output.job = db.document("jobs", data.jobId);
    await db.update("jobs", data.jobId, { updatedAt: new Date() });
    delete output.jobId;
  }
  if (data.siteId) {
    output.site = db.document("sites", data.siteId);
    await db.update("sites", data === null || data === void 0 ? void 0 : data.siteId, { updatedAt: new Date() });
    delete output.siteId;
  }
  if (data.serviceId) {
    output.service = db.document("services", data.serviceId);
    await db.update("services", data.serviceId, { updatedAt: new Date() });
    delete output.serviceId;
  }
  if (data.inventoryId) {
    output.inventory = db.document("inventories", data.inventoryId);
    await db.update("inventories", data.inventoryId, { updatedAt: new Date() });
    delete output.inventoryId;
  }
  return db.update("photos", id, output);
}
