permit and processed collection updates
This commit is contained in:
@@ -1,7 +1,12 @@
|
||||
import { AuthenticatedUser } from "../auth";
|
||||
import { orgModel } from "../organization/organization.schema";
|
||||
import { getFilterObject, getSortObject, PageQueryParams } from "../pagination";
|
||||
import { userModel } from "../user/user.schema";
|
||||
import { processedFields, processedModel } from "./processed.schema";
|
||||
import {
|
||||
processedFields,
|
||||
processedModel,
|
||||
UpdateProcessedInput,
|
||||
} from "./processed.schema";
|
||||
|
||||
export async function getProcessedPermit(permitId: String, tenantId: String) {
|
||||
return await processedModel.findOne({
|
||||
@@ -9,6 +14,25 @@ export async function getProcessedPermit(permitId: String, tenantId: String) {
|
||||
});
|
||||
}
|
||||
|
||||
export async function updateProcessed(
|
||||
input: UpdateProcessedInput,
|
||||
permitId: string,
|
||||
user: AuthenticatedUser
|
||||
) {
|
||||
return await processedModel
|
||||
.findOneAndUpdate(
|
||||
{
|
||||
$and: [{ tenantId: user.tenantId }, { pid: permitId }],
|
||||
},
|
||||
{ ...input, lastUpdateDate: new Date() },
|
||||
{ new: true }
|
||||
)
|
||||
.populate({ path: "county", select: "pid name avatar" })
|
||||
.populate({ path: "client", select: "pid name avatar" })
|
||||
.populate({ path: "assignedTo", select: "pid name avatar" })
|
||||
.populate({ path: "createdBy", select: "pid name avatar" });
|
||||
}
|
||||
|
||||
export async function listProcessedPermits(
|
||||
params: PageQueryParams,
|
||||
tenantId: string
|
||||
|
||||
Reference in New Issue
Block a user