gpt-4o-mini-2024-07-18· OpenAI
WildChat-4.8M (AI2)
Description: add a quantity field as number const mongoose = require('mongoose'); const…
- User
Description: add a quantity field as number
const mongoose = require('mongoose');
const productSchema = new mongoose.Schema({ name: { type: String, required: true, }, description: { type: String, required: true, }, price: { type: Number, required: true, min: 0, }, sizes: { type: [String], enum: ['S', 'M', 'L'], default: ['M'], }, colors: { type: [String], enum: ['red', 'blue'], }, images: { type: [String], default: [], }, stock: { type: Number, required: true, min: 0, }, rating: { type: Number, min: 0, max: 5, default: 0, } });
const Product = mongoose.model('Product', productSchema);
module.exports = Product;
codeGenerate source code based on the description above and respond in the following JSON format ONLY: ```json { "name": "prompt_name", "schema": { "type": "string", "code": "Generated code here" } } ``` IMPORTANT: - Ensure the JSON response is error-free. - Include no additional text or explanations. Respond with the JSON object only. - Assistantjson
{ "name": "Product", "schema": { "type": "string", "code": "const mongoose = require('mongoose');\n\nconst productSchema = new mongoose.Schema({\n name: {\n type: String,\n required: true,\n },\n description: {\n type: String,\n required: true,\n },\n price: {\n type: Number,\n required: true,\n min: 0,\n },\n sizes: {\n type: [String],\n enum: ['S', 'M', 'L'],\n default: ['M'],\n },\n colors: {\n type: [String],\n enum: ['red', 'blue'],\n },\n images: {\n type: [String],\n default: [],\n },\n stock: {\n type: Number,\n required: true,\n min: 0,\n },\n quantity: {\n type: Number,\n required: true,\n min: 0,\n },\n rating: {\n type: Number,\n min: 0,\n max: 5,\n default: 0,\n }\n});\n\nconst Product = mongoose.model('Product', productSchema);\n\nmodule.exports = Product;" } }