user257980
user257980

Reputation: 1089

Loopback datasource specific configs in model

Our software is used in MariaDB and Mssql enviroments, at the moment we have specific Loopback instances for different databases, models are the same. Is there way to define datasource specific conifguration to model.

 {
    "name": "Album",
    "plural": "album",
    "base": "PersistedModel",
    "idInjection": false,
    "options": {
        "validateUpsert": true
    },
    "properties": {
        "uuid": {
            "type": "string",
            "defaultFn": "uuid",
            "id": true
        },
        "description": {
            "type": "string"
            //IS IT POSSIBLE TO ADD DATASOURCE CONFIGS HERE?

        },
    }
}

Upvotes: 0

Views: 38

Answers (1)

MaSza
MaSza

Reputation: 465

You can set specific datasource to model in model-config.json

"your-model": {
    "public": true,
    "dataSource": "your-data-source-name",
 }

You can set datasources names in your datasource.json file.

Upvotes: 1

Related Questions