Add core
This commit is contained in:
1 parent
2d8dd4b0a9
commit
c7cf9b8061
58 files changed
+9873
-2
No files matched your search
@@ -0,0 +1,20 @@
|
||||
/*******************************************************************************
|
||||
* models/cart-item.js
|
||||
*
|
||||
******************************************************************************/
|
||||
import { BaseModel } from "../interfaces"
|
||||
|
||||
class CartItemModel extends BaseModel {
|
||||
static modelName = "CartItem"
|
||||
static schema = {
|
||||
type: {
|
||||
type: String,
|
||||
enum: ["product", "bundle"],
|
||||
default: "product",
|
||||
required: true,
|
||||
},
|
||||
quantity: { type: Number, min: 0, required: true },
|
||||
}
|
||||
}
|
||||
|
||||
export default CartItemModel
|
||||
@@ -0,0 +1,21 @@
|
||||
/*******************************************************************************
|
||||
* models/product-variant.js
|
||||
*
|
||||
******************************************************************************/
|
||||
import mongoose from "mongoose"
|
||||
import { BaseModel } from "../interfaces"
|
||||
|
||||
import MoneyAmountSchema from "./schemas/money-amount"
|
||||
import OptionValueSchema from "./schemas/option-value"
|
||||
|
||||
class ProductVariantModel extends BaseModel {
|
||||
static modelName = "ProductVariant"
|
||||
static schema = {
|
||||
title: { type: String, required: true },
|
||||
prices: { type: [MoneyAmountSchema], default: [], required: true },
|
||||
options: { type: [OptionValueSchema], default: [] },
|
||||
image: { type: String, default: "" },
|
||||
}
|
||||
}
|
||||
|
||||
export default ProductVariantModel
|
||||
@@ -0,0 +1,25 @@
|
||||
/*******************************************************************************
|
||||
* models/product.js
|
||||
*
|
||||
******************************************************************************/
|
||||
import mongoose from "mongoose"
|
||||
import { BaseModel } from "../interfaces"
|
||||
|
||||
import OptionSchema from "./schemas/option"
|
||||
|
||||
class ProductModel extends BaseModel {
|
||||
static modelName = "Product"
|
||||
static schema = {
|
||||
title: { type: String, required: true },
|
||||
description: { type: String, default: "" },
|
||||
tags: { type: String, default: "" },
|
||||
handle: { type: String, required: true, unique: true },
|
||||
images: { type: [String], default: [] },
|
||||
options: { type: [OptionSchema], default: [] },
|
||||
variants: { type: [String], default: [] },
|
||||
metadata: { type: mongoose.Schema.Types.Mixed, default: {} },
|
||||
published: { type: Boolean, default: false },
|
||||
}
|
||||
}
|
||||
|
||||
export default ProductModel
|
||||
@@ -0,0 +1,10 @@
|
||||
/*******************************************************************************
|
||||
* models/money-amount.js
|
||||
*
|
||||
******************************************************************************/
|
||||
import mongoose from "mongoose"
|
||||
|
||||
export default new mongoose.Schema({
|
||||
currency_code: { type: String, required: true },
|
||||
amount: { type: Number, required: true, min: 0 },
|
||||
})
|
||||
@@ -0,0 +1,6 @@
|
||||
import mongoose from "mongoose"
|
||||
|
||||
export default new mongoose.Schema({
|
||||
option_id: { type: mongoose.Types.ObjectId, required: true },
|
||||
value: { type: String, required: true },
|
||||
})
|
||||
@@ -0,0 +1,11 @@
|
||||
/*******************************************************************************
|
||||
* models/option.js
|
||||
*
|
||||
******************************************************************************/
|
||||
import mongoose from "mongoose"
|
||||
|
||||
export default new mongoose.Schema({
|
||||
product_id: { type: mongoose.Types.ObjectId, required: true },
|
||||
title: { type: String, required: true },
|
||||
values: { type: [String], default: [] },
|
||||
})
|
||||
@@ -0,0 +1,16 @@
|
||||
/*******************************************************************************
|
||||
* models/user.js
|
||||
*
|
||||
******************************************************************************/
|
||||
import { BaseModel } from "../interfaces"
|
||||
|
||||
class UserModel extends BaseModel {
|
||||
static modelName = "User"
|
||||
static schema = {
|
||||
name: { type: String, required: true },
|
||||
email: { type: String, required: true },
|
||||
passwordHash: { type: String, required: true },
|
||||
}
|
||||
}
|
||||
|
||||
export default UserModel
|
||||
Reference in new issue
Block a user