import mongoose from 'mongoose' import { apartmentSchema, buildingDataSchema } from '../index.js' export const buildingSchema = new mongoose.Schema({ prefix: { type: String, lowercase: true, default: null }, name: { type: String, default: null }, address: { type: String, default: null }, gmlId: { type: String, default: null }, data: { type: buildingDataSchema, default: {} }, apartments: [apartmentSchema], owner: mongoose.SchemaTypes.ObjectId, setupCompleted: { type: Boolean, default: false }, createdBy: mongoose.SchemaTypes.ObjectId, createdAt: { type: Date, immutable: true, default: () => Date.now() }, updatedAt: { type: Date, default: () => Date.now() } }) export default mongoose.model('Building', buildingSchema)