tango-api-schema 2.0.0 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -1,5 +1,7 @@
1
1
  import leadModel from "./schema/lead.model.js";
2
+ import otpModel from "./schema/otp.model.js";
2
3
 
3
4
  export default {
4
5
  leadModel,
6
+ otpModel
5
7
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tango-api-schema",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "description": "tangoEye model schema",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -0,0 +1,29 @@
1
+ import uniqueValidator from 'mongoose-unique-validator';
2
+ import mongoose from 'mongoose';
3
+
4
+ // schema
5
+ const collection = new mongoose.Schema( {
6
+ email: {
7
+ type: String,
8
+ trim: true,
9
+ unique: true,
10
+ },
11
+ otp: {
12
+ type: Number,
13
+ },
14
+ type: {
15
+ type: String,
16
+ enum: [ 'signup' ],
17
+ },
18
+ },
19
+ {
20
+ timestamps: true,
21
+ strict: true,
22
+ versionKey: false,
23
+ } );
24
+
25
+ collection.plugin( uniqueValidator );
26
+ collection.index( { createdAt: 1 }, { expires: '1d' } );
27
+ collection.index( { type: 1, email: 1 } );
28
+
29
+ export default mongoose.model( 'otp', collection );