-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUserConnection.js
More file actions
34 lines (24 loc) · 1.32 KB
/
UserConnection.js
File metadata and controls
34 lines (24 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/**********************************************************************/
'use strict'; // https://www.w3schools.com/js/js_strict.asp
/**********************************************************************/
const mongoose = require('mongoose');
const { Schema, model } = mongoose;
/**********************************************************************/
const { flake } = require('..');
/**********************************************************************/
const UserConnectionSchema = new Schema(
{
id: { type: String, unique: true, required: true, index: true, default: () => flake.gen() },
name: { type: String, required: true },
username: { type: String, required: true },
connected_email: { type: String, required: true },
refresh_token: { type: String, required: true },
oauth2_token: { type: String, required: true }
},
{ collection: process.env.MONGODB_USER_CONNECTIONS_COLLECTION || 'connections', timestamps: true }
);
/**********************************************************************/
UserConnectionSchema.path('id');
/**********************************************************************/
module.exports = mongoose.models.UserConnection || model('UserConnection', UserConnectionSchema);
/**********************************************************************/