--- /dev/null
+import { Knex } from "knex";
+
+
+export async function up(knex: Knex): Promise<void> {
+ return knex.schema.alterTable('locations', function(table) {
+ table.integer('display_order').notNullable().defaultTo(1);
+ });
+}
+
+
+export async function down(knex: Knex): Promise<void> {
+ return knex.schema.alterTable('locations', function(table) {
+ table.dropColumn('display_order');
+ })
+}
+
id: r.fields.id,
name: r.fields.name,
type: r.fields.Type,
- city_id: r.fields.city_id[0]
+ city_id: r.fields.city_id[0],
+ display_order: r.fields["Display Order"]
}
- })).onConflict('id').ignore();
+ })).onConflict('id').merge();
next();
}).finally(() => {
import { db } from './lib/db';
export async function getAllServices(city_id: string): Promise<Location[]> {
-
- return db.select('*').from<Location>('locations').where({city_id});
-
+ return db.select('*')
+ .from<Location>('locations')
+ .where({city_id})
+ .orderBy('type')
+ .orderBy('display_order');
}
export async function getAllPaths(city_id: string): Promise<Path[]> {
id: string;
name: string;
city_id: string;
- type: 'SERVICES' | 'STORES' | 'EXPLORE'
+ type: 'SERVICES' | 'STORES' | 'EXPLORE',
+ display_order: number;
}
export type Path = {