Model Personalization in

In this example, we will demonstrate

  • how we(as tenant) can use existing model and change it for tenant
  • how the change one tenant not affecting other tenant

What you will build

  • You will create a model called Product
  • You will create two tenants and two users each belongs to one tenant
  • As both tenant users, you will able to access Product model as is
  • tenant1 personalized model by adding additional attributes
  • tenant1 personalized model is not visible to tenant2

What you will need

  • a running NodeJS application built using the Framework.
  • an understanding of what a Model is in the context of oeCloud Framework.
  • an understanding of Model creation.
  • you need to use Swagger UI’s - Switch tenant functionality.

How to complete this Guide

Download and install sample app

Click here to download sample application.

Once you have started the server, open a browser link: http://localhost:3000/explorer/. Please use Swagger UI for this exercise when posting data or retrieving data.

Getting Started

1. Prepare data

  • By default, user’s tenant information is taken from logged in user.
  • Once application is started, login to application with user name/password as admin/admin.
  • If you are using scaffolding application, you need to login using login page provided and then browse to /explorer.
  • It may happen that instead of BaseUser you will have to user AppUser - this is based on the case if application has overriden BaseUser model
  • You can login explicitly as admin user by posting following into /api/BaseUser api (or /api/AppUsers ) api
"username" : "admin",
"password" : "admin"
  • Create two tenants - icici and citi - by posting data to Tenant model as shown below. This can also be done using Swagger UI.

Icici tenant creation

"tenantName":  "icici",

Citi tenant creation

"tenantName":  "citi",

Switching Tenant

  • Select BaseUser’s switch tenant API
  • Enter tenantId as ‘icici’
  • Click on ‘Try it Out’.
  • This will switch tenant to icici.

Create tenant User for ‘icici’

  • Post user data to BaseUser to create icici user.
  • Same thing you repeat for citi tenant.

Icici user creation


citi user creation

  • We will be using given model comes up with application which is Product model.

Product Model

    "name": "Product",
    "base": "BaseEntity",
    "strict": false,
    "plural": "Products",
    "idInjection": true,
    "options": {
        "validateUpsert": true
    "properties": {
        "code": {
            "type": "string",
            "source": "code",
            "required": true
        "name": {
            "type": "string",
            "source": "name",
            "required": true
        "category": {
            "type": "string",
            "source": "category"
        ... other properties

2. Model Personalization in action

  • Re login admin/admin/default by posting into /api/BaseUser/login method
  • Post following data to product table. ( POST /api/Products )
    "code": "M000",
    "name": "Samsung Galaxy S4",
    "category": "Mobiles",
    "price": 40000,
    "offeredSince": "2016-05-01",
    "active": true,
    "description": "Samsung Galaxy S4 Android mobile phone by ADMIN",
    "id" : 1   
  • Select BaseUser’s switch tenant API
  • Enter tenantId as ‘icici’
  • Login as icici user by posting into /api/BaseUser/login method
  • Post following data to /api/BaseUser/login API
  "username": "iciciuser",
  "password" : "icici"
  • you should able to view data posted by admin/admin ( GET /api/Products )
  • Suppose you as ICICI user, wish to add ‘discount’ field to product model. This can be done by posting following to ‘ModelDefinition’ model.
    "name": "ProductICICI",
    "base": "Product",
    "plural": "ProductICICI",
    "properties": {
        "discount": {
            "type": "number"
    "variantOf" : "Product"
  • As a ICICI user, you should able to post ‘discount’ field data to Product model and since it is personalized you as ICICI user opens the model for Posting data in oe-designer, ‘discount’ field will start appearing. this is done by posting following data to /api/Products
    "code": "M001",
    "name": "Samsung Galaxy S7",
    "category": "Mobiles",
    "price": 46000,
    "offeredSince": "2016-08-01",
    "active": true,
    "discount" : 9,
    "description": "Samsung Galaxy S7 Android mobile phone by ICICI",
    "id" : 2   
  • Login as Citi user in Swagger
  • You should not able to see data posted by ICICI tenant


  • By default, personalized model data also gets stored in same collection in mongo db.
  • If you want personalized model data to be stored in seperate collection, you should use following property while creating personalized model - while posting into ‘ModelDefinition’
    collection: 'YourCollectionName'
  • If you use above settings, you will not able to see ‘Default’ tenant data.
  • In UI application, you will see discount field if you are icici tenant.