Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const bankAccSchema = new Schema({
- user: {
- type: Schema.Types.ObjectId,
- ref: "user"
- },
- name: {
- type: String,
- required: [true, "Bank Name is Required"]
- },
- acc_number: {
- type: Number,
- required: [true, "Bank Acc Number is Required"]
- },
- acc_type: {
- type: String,
- enum: validTypes,
- required: [true, "Bank Acc Number is Required"]
- },
- country: {
- type: String //Venezuela
- },
- country_id: {
- type: String //VE
- },
- created_at: {
- type: Date,
- default: new Date()
- },
- updated_at: Date,
- deleted_at: Date,
- deleted: {
- type: Boolean,
- default: false
- }
- });
- const chatSchema = new Schema({
- transaction: {
- type: Schema.Types.ObjectId,
- ref: "transaction"
- },
- messages: [
- {
- type: Schema.Types.ObjectId,
- ref: "message"
- }
- ],
- secure_hash: String,
- created_at: { type: Date, default: new Date() },
- updated_at: Date,
- deleted_at: Date,
- deleted: { type: Boolean, default: false }
- });
- const countrySchema = new Schema({
- iso_code: String,
- country: String,
- currency: {
- iso_code: String,
- iso_symbol: String,
- name: String
- },
- created_at: {
- type: Date,
- default: new Date()
- },
- updated_at: Date,
- deleted_at: Date,
- deleted: {
- type: Boolean,
- default: false
- }
- });
- const groupSchema = new Schema({
- title: String,
- wallet: {
- type: Schema.Types.ObjectId,
- ref: "wallet"
- },
- owners: [
- {
- type: Schema.Types.ObjectId,
- ref: "user"
- }
- ],
- members: [
- {
- type: Schema.Types.ObjectId,
- ref: "user"
- }
- ],
- created_at: { type: Date, default: new Date() },
- updated_at: Date,
- deleted_at: Date,
- deleted: { type: Boolean, default: false }
- });
- const messageSchema = new Schema({
- chat: {
- type: Schema.Types.ObjectId,
- ref: "chat"
- },
- sender: {
- type: Schema.Types.ObjectId,
- ref: "user"
- },
- receiver: {
- type: Schema.Types.ObjectId,
- ref: "user"
- },
- content: String,
- type_file: {
- type: String,
- enum: validTypes
- },
- attached: String,
- has_attached: { type: Boolean, default: false },
- status: {
- type: String,
- default: "sending",
- enum: validStatus
- },
- secure_hash: String,
- created_at: { type: Date, default: new Date() },
- updated_at: Date,
- deleted_at: Date,
- deleted: { type: Boolean, default: false }
- });
- const notificationSchema = new Schema({
- sender: {
- type: Schema.Types.ObjectId,
- ref: "user"
- },
- receiver: {
- type: Schema.Types.ObjectId,
- ref: "user"
- },
- title: {
- type: String,
- required: [true, "Title for notification is Required"]
- },
- message: {
- type: String,
- required: [true, "Message is Required"]
- },
- link: {
- type: String
- /**
- * Link para llevarlo directo a la transaccion o a la noticia que se este transmitiendo
- */
- },
- read: {
- type: Boolean,
- default: false
- },
- created_at: {
- type: Date,
- default: new Date()
- },
- updated_at: Date,
- deleted_at: Date,
- deleted: {
- type: Boolean,
- default: false
- }
- });
- const profileSchema = new Schema({
- first_name: String,
- last_name: String,
- full_name: String,
- birthday: Date,
- address_1: String,
- address_2: String,
- dni: String,
- zip_code: {
- type: String,
- validate: {
- validator: v => {
- return /^[0-9]{4,5}(?:-[0-9]{4})?$/g.test(v);
- },
- message: () => `Invalid Zip-Code`
- }
- },
- phone_1: Number,
- phone_2: Number,
- country: String,
- country_id: String, // ex: VE
- created_at: { type: Date, default: new Date() },
- updated_at: Date,
- deleted_at: Date,
- deleted: Boolean,
- user: {
- type: Schema.Types.ObjectId,
- ref: "user"
- }
- });
- const referralSchema = new Schema({
- by: { type: Schema.Types.ObjectId, ref: "user" },
- user: { type: Schema.Types.ObjectId, ref: "user" },
- status: { type: String, default: "uncompleted", enum: status }, // True = Completo la condicion para que ambos tengan el reward
- created_at: { type: Date, default: new Date() },
- updated_at: Date,
- deleted_at: Date,
- deleted: { type: Boolean, default: false }
- });
- const ticketSchema = new Schema({
- user: {
- type: Schema.Types.ObjectId,
- ref: "user"
- },
- agent: {
- type: Schema.Types.ObjectId,
- ref: "user"
- },
- status: {
- type: String,
- default: "pending",
- enum: validStatus
- },
- issue: String,
- category: {
- type: String,
- enum: validCategories
- },
- created_at: { type: Date, default: new Date() },
- updated_at: Date,
- deleted_at: Date,
- deleted: { type: Boolean, default: false }
- });
- const validStatus = {
- values: ["pending", "accepted", "confirmed", "completed", "cancelled", "expired"],
- message: `{VALUE} is not a valid status`
- };
- const validPaymentMethods = {
- values: [
- "e_tranfer",
- "bank_tranfer",
- "cash",
- "cryptocurrency",
- "gift_card",
- "mobile"
- ],
- message: `{VALUE} is not a valid payment method`
- };
- const validTypes = {
- values: ["withdraw", "deposit", "tranfer", "send", "received"],
- message: `{VALUE} is not a valid payment method`
- };
- const transactionSchema = new Schema({
- sender: {
- type: Schema.Types.ObjectId, // seller
- ref: "user"
- },
- receiver: {
- type: Schema.Types.ObjectId, // buyer
- ref: "user"
- },
- chat: {
- type: Schema.Types.ObjectId,
- ref: "chat"
- },
- balance: Number,
- location: String, // Country -> Venezuela
- flag: String, // country_id -> VE
- status: {
- type: String,
- enum: validStatus,
- default: "pending"
- },
- amount: Number,
- fee: Number,
- local_currency: String,
- exchange_currency: { type: String, default: 'KlippUSD'},
- pair: String, // this.local_currency:this.exchange_currency --- KlippUSD/BsS or BsS/KlippUSD
- payment_method: {
- type: String,
- enum: validPaymentMethods
- },
- exchange_rate: Number, // ex: 345 BsS -> 1$ === 345 BsS
- typo: {
- type: String,
- enum: validTypes
- },
- created_at: { type: Date, default: new Date() },
- updated_at: Date,
- deleted_at: Date,
- deleted: { type: Boolean, default: false }
- });
- const UserSchema = new Schema({
- email: {
- type: String,
- required: [true, "Email is required"],
- validate: {
- validator: function(value) {
- return /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/.test(
- value
- );
- },
- message: () => `Invalid Email`
- },
- unique: true
- },
- password: {
- type: String,
- required: [true, "Password is required"],
- validate: {
- validator: function(value) {
- return /^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[#?!@$%.^&/*-]).{6,}$/.test(
- value
- );
- },
- message: () => `Invalid Password`
- /*
- TODO: put this message in the front-end
- At least one upper case English letter, (?=.*?[A-Z])
- At least one lower case English letter, (?=.*?[a-z])
- Non ñ-Ñ
- At least one digit, (?=.*?[0-9])
- At least one special character, (?=.*?[#?!@$%^&*-])
- Minimum six in length .{6,} (with the anchors)
- */
- }
- },
- user_agent: {
- ip: String,
- country_id: String, // VE,
- country: String, // VENEZUELA,
- browser: String,
- },
- access_token: String,
- validate_link: String,
- recover_code: String,
- validated: { type: Boolean, default: false },
- show_email: { type: Boolean, default: true },
- language: { type: String, default: "en" }, // EN/ES
- rate: { type: Number, default: 0 }, // [0 a 10]
- created_at: { type: Date, default: new Date() },
- updated_at: Date,
- deleted_at: Date,
- last_enter: Date,
- deleted: { type: Boolean, default: false },
- role: {
- type: String,
- default: "regular",
- enum: roles
- },
- currency: { type: String, default: "Klipp-USD" },
- status: {
- type: String,
- default: "active",
- enum: status
- },
- verified: { type: Boolean, default: false }, // All fields verified
- verified_email: { type: Boolean, default: false }, // Verified email
- verified_docs: { type: Boolean, default: false }, // Verified Document -- DNI || Passport || drive licence
- documents: {
- dni: String, // path image
- passport: String, // path image
- drive_lic: String, // path image
- face_photo: String // path image
- },
- profile: {
- type: Schema.Types.ObjectId,
- ref: "profile"
- },
- referral_code: { type: String },
- referrals: [
- {
- type: Schema.Types.ObjectId,
- ref: "referral"
- }
- ],
- wallets: [
- {
- type: Schema.Types.ObjectId,
- ref: "wallet"
- }
- ],
- groups: [
- {
- type: Schema.Types.ObjectId,
- ref: "group"
- }
- ],
- transactions: [
- {
- type: Schema.Types.ObjectId,
- ref: "transaction"
- }
- ],
- tickets: [
- {
- type: Schema.Types.ObjectId,
- ref: "ticket"
- }
- ],
- bank_accounts: [
- {
- type: Schema.Types.ObjectId,
- ref: "bankAccount"
- }
- ]
- });
- const walletSchema = new Schema({
- user: {
- type: Schema.Types.ObjectId,
- ref: "user"
- },
- group: {
- type: Schema.Types.ObjectId,
- ref: "group"
- },
- address: String,
- currency: String, // USD === KlippUSD
- symbol: String, // USD - K-USD - Klipps
- balance: { type: Number, default: 0.0 },
- wallet_type: {
- type: String,
- enum: validTypes
- },
- created_at: { type: Date, default: new Date() },
- updated_at: Date,
- deleted_at: Date,
- deleted: { type: Boolean, default: false }
- });
Add Comment
Please, Sign In to add comment