mirror of
https://github.com/myfatemi04/wheelshare-old-backend.git
synced 2025-04-21 12:10:17 -04:00
update models
This commit is contained in:
parent
f454f31d32
commit
db8da4a55e
|
@ -92,6 +92,6 @@ export async function getAccountIDFromIonCode(code: string) {
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
return await registerUserFromIonProfile(profile);
|
return await registerUserFromIonProfile(profile);
|
||||||
} else {
|
} else {
|
||||||
return user.uuid;
|
return user._id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,22 @@
|
||||||
import { model, Schema } from 'mongoose';
|
import { model, Schema, Document, Model } from 'mongoose';
|
||||||
|
|
||||||
|
export interface User extends Document {
|
||||||
|
email: string;
|
||||||
|
username: string;
|
||||||
|
first_name: string;
|
||||||
|
last_name: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Group extends Document {
|
||||||
|
member_ids: string[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Comment {
|
||||||
|
body: string;
|
||||||
|
author_id: string;
|
||||||
|
}
|
||||||
|
|
||||||
const UserSchema: Schema = new Schema({
|
const UserSchema: Schema = new Schema({
|
||||||
uuid: { type: String, required: true },
|
|
||||||
email: { type: String, required: true },
|
email: { type: String, required: true },
|
||||||
username: { type: String, required: true },
|
username: { type: String, required: true },
|
||||||
first_name: { type: String, required: true },
|
first_name: { type: String, required: true },
|
||||||
|
@ -12,23 +27,37 @@ UserSchema.virtual('fullName').get(function (this) {
|
||||||
return this.firstName + this.lastName;
|
return this.firstName + this.lastName;
|
||||||
});
|
});
|
||||||
|
|
||||||
const UserModel = model('User', UserSchema);
|
const UserModel: Model<User> = model('User', UserSchema);
|
||||||
|
|
||||||
const GroupSchema: Schema = new Schema({
|
const GroupSchema: Schema = new Schema({
|
||||||
id: { type: String, required: true },
|
|
||||||
member_ids: { type: [String], required: true },
|
member_ids: { type: [String], required: true },
|
||||||
});
|
});
|
||||||
|
|
||||||
const GroupModel = model('Group', GroupSchema);
|
const GroupModel = model('Group', GroupSchema);
|
||||||
|
|
||||||
const CommentSchema: Schema = new Schema({
|
const CommentSchema: Schema = new Schema({
|
||||||
id: { type: String, required: true },
|
|
||||||
text: { type: String, required: true },
|
text: { type: String, required: true },
|
||||||
author_id: { type: String, required: true },
|
author_id: { type: String, required: true },
|
||||||
});
|
});
|
||||||
|
|
||||||
const CommentModel = model('Comment', CommentSchema);
|
const CommentModel = model('Comment', CommentSchema);
|
||||||
|
|
||||||
|
export interface Pool extends Document {
|
||||||
|
title: string;
|
||||||
|
description: string;
|
||||||
|
participant_ids: string[];
|
||||||
|
driver_id: string;
|
||||||
|
create_time: string;
|
||||||
|
update_time: string;
|
||||||
|
comments: Comment[];
|
||||||
|
group_id: string;
|
||||||
|
status: 'pending' | 'cancelled' | 'completed' | 'interrupted';
|
||||||
|
capacity: number;
|
||||||
|
direction: 'pickup' | 'dropoff';
|
||||||
|
author_id: string;
|
||||||
|
type: 'request' | 'offer';
|
||||||
|
}
|
||||||
|
|
||||||
const PoolSchema: Schema = new Schema({
|
const PoolSchema: Schema = new Schema({
|
||||||
id: { type: String, required: true },
|
id: { type: String, required: true },
|
||||||
title: { type: String, required: true },
|
title: { type: String, required: true },
|
||||||
|
@ -46,6 +75,6 @@ const PoolSchema: Schema = new Schema({
|
||||||
type: { type: String, required: true },
|
type: { type: String, required: true },
|
||||||
});
|
});
|
||||||
|
|
||||||
const PoolModel = model('Pool', PoolSchema);
|
const PoolModel: Model<Pool> = model('Pool', PoolSchema);
|
||||||
|
|
||||||
export { UserModel, GroupModel, CommentModel, PoolModel };
|
export { UserModel, GroupModel, CommentModel, PoolModel };
|
||||||
|
|
39
src/types.ts
39
src/types.ts
|
@ -1,39 +0,0 @@
|
||||||
namespace Carpool {
|
|
||||||
export interface Group {
|
|
||||||
id: string;
|
|
||||||
member_ids: string[];
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface User {
|
|
||||||
uuid: string;
|
|
||||||
email: string;
|
|
||||||
username: string;
|
|
||||||
first_name: string;
|
|
||||||
last_name: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface Comment {
|
|
||||||
id: string;
|
|
||||||
body: string;
|
|
||||||
author_id: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export type Status = 'pending' | 'cancelled' | 'completed' | 'interrupted';
|
|
||||||
|
|
||||||
export interface Pool {
|
|
||||||
id: string;
|
|
||||||
title: string;
|
|
||||||
description: string;
|
|
||||||
participant_ids: string[];
|
|
||||||
driver_id: string;
|
|
||||||
create_time: string;
|
|
||||||
update_time: string;
|
|
||||||
comments: Comment[];
|
|
||||||
group_id: string;
|
|
||||||
status: Status;
|
|
||||||
capacity: number;
|
|
||||||
direction: 'pickup' | 'dropoff';
|
|
||||||
author_id: string;
|
|
||||||
type: 'request' | 'offer';
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user