Institute User Model
Business Purpose: An extension of the base User model, specific to an institute. It links a core system user to an institute and defines their role within that institute (e.g., "Institute Admin").
Core Concept: Extending the Built-in User
This design pattern is used to add application-specific information to the core user system without modifying it directly. Here’s how it works:
-
Core
UserModel: Your SolidX application has a built-inUsermodel provided by the core framework. Its primary job is to handle authentication (i.e., verifying a user's identity with a username and password so they can log in). -
InstituteUserModel: To give a user special permissions related to an institute, you create a newInstituteUsermodel. This model is defined as a "Child Model" of the coreUsermodel. -
The Connection: The
InstituteUsermodel doesn't replace theUsermodel; it extends it. It holds additional information that is only relevant to your specific application, such as:- A link to the
Userit belongs to. - A link to the specific
institutethe user manages. - The user's role within that institute (e.g., "Institute Admin").
- A link to the
In simple terms: A person can log in because they exist in the central User table. The system then checks the InstituteUser table to see if that logged-in user is linked to an institute. If a link exists, the system knows they are an "Institute Admin" and grants them the necessary permissions.
This approach is a best practice because it keeps your application's logic separate from the core framework, making the system more modular, secure, and easier to upgrade.
Fields:
| Field Name | Type | Description |
|---|---|---|
userType | selectionStatic | The type of user (e.g., Institute Admin). |
institute | relation | A many-to-one relationship to the institute model. |
Key Fields Explained
- Child Model (
isChild: true): This is a special type of model in SolidX. Notice theisChild: trueandparentModelUserKey: "user"properties in the JSON. This tells SolidX thatInstituteUseris not a standalone entity; instead, it extends the built-inUsermodel from the Solid Core module. - How it Works: When you create a new
Userin the system, you can now also create an associatedInstituteUserrecord for them. This allows you to add institute-specific properties (likeuserTypeand theinstitutethey belong to) to a core user, which is a powerful pattern for multi-tenancy. A single user could potentially have roles in multiple institutes by having multipleInstituteUserrecords.
Creation Steps
If you are following the manual "Guided Tour", follow these steps to create the Institute User model in the App Builder.
- Navigate to Fees Portal > App Builder > Model and click Add.
- Fill in the primary details for the model:
- Singular Name:
instituteUser - Plural Name:
instituteUsers - Display Name:
Institute User - Is Child Model: Check this box.
- Parent Model: Select
userfrom the dropdown.
- Singular Name:
- Go to the Fields tab.
- Click Add Field and create each field exactly as defined in the table above.
- Click Save.
You're Done with Data Modeling! Once you have created this final model, you have finished the data modeling stage. The last step is to generate the code for all the new models you've created. In your
solid-apiterminal, run:
solid refresh-module -n fees-portalThis command will create all the necessary backend files for your new models. After it completes and the server restarts, you will see all your new models appear in the sidebar under the "Fees Portal" menu.
For the Fast Track: Model Metadata The JSON block below contains the complete metadata definition for the Institute User model.
This definition is structured with top-level properties for the model itself (like
singularName,pluralName,tableName) and afieldsarray that defines every attribute you see in the table above.You can use this metadata as part of the "Fast Track" approach by including it in the main
fees-portal-metadata.jsonfile.
{
"singularName": "instituteUser",
"pluralName": "instituteUsers",
"displayName": "Institute User",
"description": "This table allows us to store institute user records",
"dataSource": "default",
"dataSourceType": "postgres",
"tableName": "fees_portal_institute_user",
"isChild": true,
"parentModelUserKey": "user",
"enableAuditTracking": true,
"enableSoftDelete": false,
"draftPublishWorkflow": false,
"internationalisation": false,
"fields": [
{
"name": "userType",
"displayName": "User Type",
"description": null,
"type": "selectionStatic",
"ormType": "varchar",
"isSystem": false,
"defaultValue": "Institute Admin",
"selectionStaticValues": [
"Institute Admin:Institute Admin"
],
"selectionValueType": "string",
"required": true,
"unique": false,
"index": false,
"private": false,
"encrypt": false,
"encryptionType": null,
"decryptWhen": null,
"columnName": null,
"enableAuditTracking": true,
"isMultiSelect": false
},
{
"name": "institute",
"displayName": "Institute",
"description": null,
"type": "relation",
"ormType": "integer",
"isSystem": false,
"relationType": "many-to-one",
"relationCoModelFieldName": "instituteUsers",
"relationCreateInverse": true,
"relationCoModelSingularName": "institute",
"relationCoModelColumnName": null,
"relationModelModuleName": "fees-portal",
"relationCascade": "cascade",
"required": false,
"unique": false,
"index": false,
"private": false,
"encrypt": false,
"encryptionType": null,
"decryptWhen": null,
"columnName": null,
"relationJoinTableName": null,
"isRelationManyToManyOwner": null,
"relationFieldFixedFilter": "",
"enableAuditTracking": true
}
]
}