mirror of
https://github.com/Litlyx/litlyx
synced 2025-12-10 07:48:37 +01:00
fix counts on project creation
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { ProjectModel, TProject } from "@schema/ProjectSchema";
|
||||
import { ProjectCountModel } from "@schema/ProjectsCounts";
|
||||
import StripeService from '~/server/services/StripeService';
|
||||
|
||||
export default defineEventHandler(async event => {
|
||||
@@ -32,6 +33,11 @@ export default defineEventHandler(async event => {
|
||||
premium_expire_at: subscription.current_period_end * 1000
|
||||
});
|
||||
|
||||
await ProjectCountModel.create({
|
||||
project_id: project._id,
|
||||
events: 0,
|
||||
visits: 0
|
||||
});
|
||||
|
||||
return project.toJSON() as TProject;
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ export type TProjectCount = {
|
||||
}
|
||||
|
||||
const ProjectCountSchema = new Schema<TProjectCount>({
|
||||
project_id: { type: Types.ObjectId, index: 1 },
|
||||
project_id: { type: Types.ObjectId, index: true, unique: true },
|
||||
events: { type: Number, required: true, default: 0 },
|
||||
visits: { type: Number, required: true, default: 0 },
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user