Skip to content

Commit

Permalink
Migrated Disease and Hospital API to Mongoose
Browse files Browse the repository at this point in the history
  • Loading branch information
ad956 committed Jul 3, 2024
1 parent 2f30be1 commit ad8a0c9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions app/api/gethospitals/disease/route.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import CommonDiseases from "@models/commonDisease";
import dbConfig from "@utils/db";

export async function GET() {
try {
const db = await dbConfig();
const collection = db.collection("commonDiseases");
await dbConfig();

const result = await collection.findOne();
const result = await CommonDiseases.findOne();

if (!result) {
return Response.json(
Expand Down
8 changes: 4 additions & 4 deletions app/api/gethospitals/route.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import CityStateHospital from "@models/citystate_hospitals";
import dbConfig from "@utils/db";

export async function GET(req: Request) {
Expand All @@ -12,10 +13,9 @@ export async function GET(req: Request) {
});
}

const db = await dbConfig();
const collection = db.collection("citystate_hospitals");
await dbConfig();

const stateHospitals = await collection.findOne({
const stateHospitals = await CityStateHospital.findOne({
[state]: { $exists: true },
});

Expand All @@ -25,7 +25,7 @@ export async function GET(req: Request) {
});
}

const cityHospitals = stateHospitals[state][city];
const cityHospitals = stateHospitals.get(state)[city];

if (!cityHospitals) {
return new Response("No hospitals found in the specified city", {
Expand Down

0 comments on commit ad8a0c9

Please sign in to comment.