Getting Started
Applied Actions
Model Schemas
Components
Bus Schema
The `busSchema` defines a MongoDB schema with fields `id`, `busName`, `nominalKV`, and `additionalFields`, where `busName` and `nominalKV` are required strings, and `additionalFields` is a flexible mixed type with default empty object. Additionally, it enables change stream pre- and post-images for the collection.
In the src/content/docs/models directory, You can find the bus.mdx
Functions
const busSchema = new Schema(
{
id: {
type: String,
},
busName: {
type: String,
required: true,
},
nominalKV: {
type: String,
required: true,
},
additionalFields: {
type: Schema.Types.Mixed,
default: {},
},
},
{
collectionOptions: { changeStreamPreAndPostImages: { enabled: true } },
}
);
The busSchema outlines the structure for documents in a MongoDB collection, likely storing data about buses. It mandates fields like id, busName, and nominalKV (representing unique ID, bus name, and kVA rating respectively). The schema allows for additional flexible fields (additionalFields) and enables change stream pre and post images for real-time data tracking.