@cendo/database-schemas 1.0.0

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/README.md ADDED
@@ -0,0 +1 @@
1
+ # @cendo/database-schemas
package/index.js ADDED
@@ -0,0 +1,3 @@
1
+ const path = require('path')
2
+
3
+ module.exports = path.join(__dirname, 'schemas')
package/package.json ADDED
@@ -0,0 +1,15 @@
1
+ {
2
+ "name": "@cendo/database-schemas",
3
+ "version": "1.0.0",
4
+ "description": "",
5
+ "main": "index.js",
6
+ "keywords": [],
7
+ "author": "",
8
+ "license": "ISC",
9
+ "peerDependencies": {
10
+ "mongoose": "^8.10.1"
11
+ },
12
+ "devDependencies": {
13
+ "mongoose": "^8.10.1"
14
+ }
15
+ }
@@ -0,0 +1,46 @@
1
+ const {Schema} = require('mongoose')
2
+ const ShippingAddress = require('./types/ShippingAddress')
3
+
4
+
5
+ const Order = new Schema({
6
+ type: {
7
+ type: String,
8
+ trim: true,
9
+ default: 'tiktok',
10
+ },
11
+
12
+ order_id: {
13
+ type: String,
14
+ trim: true,
15
+ index: true,
16
+ required: true
17
+ },
18
+
19
+ shipping_address: {
20
+ type: ShippingAddress,
21
+ },
22
+
23
+ note: {
24
+ type: String,
25
+ trim: true,
26
+ },
27
+
28
+ payment_method: {
29
+ type: String,
30
+ trim: true,
31
+ },
32
+
33
+ updated_at: {
34
+ type: Date,
35
+ default: Date.now
36
+ },
37
+
38
+ created_at: {
39
+ type: Date,
40
+ default: Date.now,
41
+ index: true,
42
+ }
43
+ })
44
+
45
+ module.exports = Order
46
+
@@ -0,0 +1,53 @@
1
+ const {Schema} = require('mongoose')
2
+
3
+
4
+ const OrderItem = new Schema({
5
+ order: {
6
+ type: Schema.Types.ObjectId,
7
+ required: true,
8
+ index: true,
9
+ },
10
+
11
+ sku_id: {
12
+ type: String,
13
+ trim: true,
14
+ index: true,
15
+ },
16
+
17
+ seller_sku: {
18
+ type: String,
19
+ trim: true,
20
+ },
21
+
22
+ product_name: {
23
+ type: String,
24
+ trim: true,
25
+ },
26
+
27
+ variant_name: {
28
+ type: String,
29
+ trim: true,
30
+ },
31
+
32
+ quantity: {
33
+ type: Number,
34
+ default: 1,
35
+ },
36
+
37
+ updated_at: {
38
+ type: Date,
39
+ default: Date.now
40
+ },
41
+
42
+ created_at: {
43
+ type: Date,
44
+ default: Date.now,
45
+ }
46
+ })
47
+
48
+ OrderItem.index({
49
+ order: 1,
50
+ sku_id: 1,
51
+ })
52
+
53
+ module.exports = OrderItem
@@ -0,0 +1,38 @@
1
+ const {Schema} = require('mongoose')
2
+
3
+
4
+ const ShippingAddress = new Schema({
5
+ _id: false,
6
+
7
+ username: {
8
+ type: String,
9
+ trim: true,
10
+ },
11
+
12
+ name: {
13
+ type: String,
14
+ trim: true,
15
+ },
16
+
17
+ country: {
18
+ type: String,
19
+ trim: true,
20
+ },
21
+
22
+ province: {
23
+ type: String,
24
+ trim: true
25
+ },
26
+
27
+ district: {
28
+ type: String,
29
+ trim: true
30
+ },
31
+
32
+ phone: {
33
+ type: String,
34
+ trim: true,
35
+ },
36
+ })
37
+
38
+ module.exports = ShippingAddress