const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
const require_utils_validation_validateOrganization = require('../utils/validation/validateOrganization.cjs');
const require_schemas_plans_schema = require('./plans.schema.cjs');
let mongoose = require("mongoose");
mongoose = require_rolldown_runtime.__toESM(mongoose);

//#region src/schemas/organization.schema.ts
const organizationSchema = new mongoose.Schema({
	name: {
		type: String,
		required: true,
		minlength: require_utils_validation_validateOrganization.NAME_MIN_LENGTH,
		maxlength: require_utils_validation_validateOrganization.NAME_MAX_LENGTH
	},
	membersIds: {
		type: [mongoose.Schema.Types.ObjectId],
		ref: "User",
		required: true,
		minlength: require_utils_validation_validateOrganization.MEMBERS_MIN_LENGTH
	},
	adminsIds: {
		type: [mongoose.Schema.Types.ObjectId],
		ref: "User",
		required: true,
		minlength: require_utils_validation_validateOrganization.MEMBERS_MIN_LENGTH
	},
	creatorId: {
		type: mongoose.Schema.Types.ObjectId,
		ref: "User",
		required: true
	},
	plan: { type: require_schemas_plans_schema.planSchema }
}, {
	timestamps: true,
	toJSON: {
		virtuals: true,
		versionKey: false,
		transform(_doc, ret) {
			const { _id,...rest } = ret;
			return {
				...rest,
				id: _id.toString()
			};
		}
	},
	toObject: {
		virtuals: true,
		transform(_doc, ret) {
			const { _id,...rest } = ret;
			return {
				...rest,
				id: _id
			};
		}
	}
});
organizationSchema.virtual("id").get(function() {
	return this._id.toString();
});

//#endregion
exports.organizationSchema = organizationSchema;
//# sourceMappingURL=organization.schema.cjs.map