UNPKG

desi-mongoose

Version:

A fun and intuitive MongoDB ODM for Node.js with a Hinglish twist

36 lines (35 loc) 982 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DesiSchema = void 0; class DesiSchema { constructor(fields) { this.fields = fields; console.log('📝 Naya schema ban gaya!'); } validate(data) { for (const [field, config] of Object.entries(this.fields)) { if (config.required && !data[field]) { throw new Error(`Arre ${field} toh daalo bhai!`); } if (data[field] && config.validate && !config.validate(data[field])) { throw new Error(`${field} mein gadbad hai!`); } } return true; } static String(options = {}) { return { type: String, required: false, ...options }; } static Number(options = {}) { return { type: Number, required: false, ...options }; } } exports.DesiSchema = DesiSchema;