import mongoose from "mongoose";
const Schema = mongoose.Schema;

const MAPPING_SCHEMA = new Schema({
    match: {
        code: String,
        key: String,
        event: { type: String, required: true},
        css: {type : String},
        xpath: {type : String},
    },
    output: {
        prefix: {type: String, required: true},
        suffix: String,
    },
    context: {
        url:String,
        css:String,
        xpath:String
    }
},
{
    timestamps: true,
});

const WEBSITE_SCHEMA = new Schema({
    _id: {type: String, required: true},
    mappingList: [MAPPING_SCHEMA],
    name: {
        dropDups: true,
        required: true,
        type: String
    },
    url:{type: String}
},
{
    timestamps: true,
});

export default mongoose.model("WebSite", WEBSITE_SCHEMA);
