building.js 838 Bytes
Newer Older
abergavenny's avatar
abergavenny committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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)