-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1366 from andrew-bierman/backend-update-trip-feature
Update Trip endpoints
- Loading branch information
Showing
12 changed files
with
213 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { protectedProcedure } from '../../trpc'; | ||
import * as validator from '@packrat/validations'; | ||
import { setTripVisibilityService } from '../../services/trip/trip.service'; | ||
|
||
export function setTripVisibilityRoute() { | ||
return protectedProcedure | ||
.input(validator.setTripVisibility) | ||
.mutation(async (opts) => { | ||
const trip = await setTripVisibilityService(opts.input); | ||
return trip; | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,34 @@ | ||
import { eq } from 'drizzle-orm'; | ||
import { DbClient } from '../../db/client'; | ||
import { type InsertGeoJson, geojson } from '../../db/schema'; | ||
|
||
export class GeoJson { | ||
async create(geoJSON: InsertGeoJson) { | ||
try { | ||
const db = DbClient.instance; | ||
const record = await db | ||
.insert(geojson) | ||
.values({ geoJSON }) | ||
.returning() | ||
.get(); | ||
const record = await db.insert(geojson).values(geoJSON).returning().get(); | ||
return record; | ||
} catch (error) { | ||
throw new Error(`Failed to create geojson record: ${error.message}`); | ||
} | ||
} | ||
|
||
async update( | ||
id: string, | ||
data: Partial<InsertGeoJson>, | ||
filter = eq(geojson.id, id), | ||
) { | ||
try { | ||
const geojsonValue = await DbClient.instance | ||
.update(geojson) | ||
.set(data) | ||
.where(filter) | ||
.returning() | ||
.get(); | ||
|
||
return geojsonValue; | ||
} catch (error) { | ||
throw new Error(`Failed to geojson record: ${error.message}`); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.