Other

Table of Contents:

DiffBlock

/models/User.js

1import mongoose from "mongoose";
2import toJSON from "./plugins/toJSON";
3
4const userSchema = mongoose.Schema(
5  {
6    name: {
7      type: String,
8      trim: true,
9    },
10    email: {
11      type: String,
12      trim: true,
13      lowercase: true,
14      private: true,
15    },
16    image: {
17      type: String,
18    },
19    customerId: {
20      type: String,
21      validate(value) {
22        return value.includes("cus_");
23      },
24    },
25    priceId:
26    variantId: {
27      type: String,
28      validate(value) {
29        return value.includes("price_");
30      },
31    },
32    hasAccess: {
33      type: Boolean,
34      default: false,
35    },
36  },
37  {
38    timestamps: true,
39    toJSON: { virtuals: true },
40  }
41);
42
43userSchema.plugin(toJSON);
44
45export default mongoose.models.User || mongoose.model("User", userSchema);

Icons

Embed

Auto-fill Stripe's Test Card | Marvin

Stripe's Test Card Filler

Marvin