Server is done

This commit is contained in:
2024-10-17 15:47:39 -05:00
parent f734551d3a
commit 69a6bb656e
11 changed files with 370 additions and 13 deletions

View File

@@ -28,9 +28,9 @@ export const users = pgTable(
metadata: jsonb('metadata'),
},
(table) => ({
appleIdIndex: index('apple_id_idx').on(table.appleId),
emailIndex: index('email_idx').on(table.email),
fullNameIndex: index('full_name_idx').on(table.fullName),
appleIdIndex: index('users_apple_id_idx').on(table.appleId),
emailIndex: index('users_email_idx').on(table.email),
fullNameIndex: index('users_full_name_idx').on(table.fullName),
})
);
@@ -46,7 +46,7 @@ export const relationships = pgTable(
.default(sql`CURRENT_TIMESTAMP`).notNull(),
},
(table) => ({
requestorIdIndex: index('requestor_id_idx').on(table.requestorId),
requestorIdIndex: index('relationships_requestor_id_idx').on(table.requestorId),
})
);
@@ -58,8 +58,8 @@ export const userRelationships = pgTable(
relationshipId: integer('relationship_id').references(() => relationships.id).notNull(),
},
(table) => ({
userIdIndex: index('user_id_idx').on(table.userId),
relationshipIdIndex: index('relationship_id_idx').on(table.relationshipId),
userIdIndex: index('user_relationships_user_id_idx').on(table.userId),
relationshipIdIndex: index('user_relationships_relationship_id_idx').on(table.relationshipId),
})
);
@@ -75,7 +75,7 @@ export const countdowns = pgTable(
.default(sql`CURRENT_TIMESTAMP`).notNull(),
},
(table) => ({
relationshipIdIndex: index('relationship_id_idx').on(table.relationshipId),
relationshipIdIndex: index('countdowns_relationship_id_idx').on(table.relationshipId),
})
);
@@ -94,8 +94,8 @@ export const messages = pgTable(
hasQuickReply: boolean('has_quick_reply').default(false),
},
(table) => ({
senderIdIndex: index('sender_id_idx').on(table.senderId),
receiverIdIndex: index('receiver_id_idx').on(table.receiverId),
senderIdIndex: index('messages_sender_id_idx').on(table.senderId),
receiverIdIndex: index('messages_receiver_id_idx').on(table.receiverId),
})
);
@@ -115,7 +115,7 @@ export const media = pgTable(
order: integer('order'),
},
(table) => ({
messageIdIndex: index('message_id_idx').on(table.messageId),
messageIdIndex: index('media_message_id_idx').on(table.messageId),
})
);
@@ -128,7 +128,7 @@ export const locations = pgTable(
longitude: numeric('longitude').notNull(),
},
(table) => ({
messageIdIndex: index('message_id_idx').on(table.messageId),
messageIdIndex: index('locations_message_id_idx').on(table.messageId),
})
);
@@ -145,7 +145,7 @@ export const quickReplies = pgTable(
keepIt: boolean('keep_it').default(false),
},
(table) => ({
messageIdIndex: index('message_id_idx').on(table.messageId),
messageIdIndex: index('quick_replies_message_id_idx').on(table.messageId),
})
);
@@ -158,6 +158,6 @@ export const quickReplyOptions = pgTable(
value: varchar('value', { length: 100 }).notNull(),
},
(table) => ({
quickReplyIdIndex: index('quick_reply_id_idx').on(table.quickReplyId),
quickReplyIdIndex: index('qr_options_quick_reply_id_idx').on(table.quickReplyId),
})
);

View File

@@ -140,6 +140,17 @@ export const updatePushToken = async (userId: number, pushToken: string): Promis
}
};
export const getPfpUrl = async (userId: number) => {
try {
const users = await db.select().from(schema.users)
.where(eq(schema.users.id, userId))
const user = users[0] as User;
return (users === undefined) ? user.pfpUrl : null;
} catch (error) {
console.error('Error getting pfp url:', error);
}
};
export const updatePfpUrl = async (userId: number, pfpUrl: string) => {
try {
const result = await db.update(schema.users)