Package Exports
- loopback-component-meta
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (loopback-component-meta) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
loopback-component-meta
Component for LoopBack that adds a Meta model that can be used to retrieve meta data about the model definitions.
Installation
Install the module
$ npm install --save loopback-component-metaConfigure the module in server/component-config.json
{
"loopback-component-meta": {
"enableRest": true,
"filter": [
"ACL",
"AccessToken",
"RoleMapping",
"Role",
"User"
],
"acls": [{
"accessType": "*",
"principalType": "ROLE",
"principalId": "$unauthenticated",
"permission": "ALLOW"
}]
}
}Usage
After installation you should be able to retrieve data about your models through the Meta endpoint on your API:
Retrieve all models:
[{
id: "Category",
name: "Category",
properties: {
name: {
type: "String",
required: true
}
},
acls: [],
base: "BaseModel",
idInjection: true,
methods: {},
mixins: {
ModifiedTimestamp: {}
},
relations: {
products: {
type: "hasMany",
model: "Product",
foreignKey: ""
}
},
strict: false,
validations: []
}, {
id: "Product",
name: "Product",
properties: {
name: {
type: "String",
required: true
}
},
acls: [],
base: "BaseModel",
idInjection: true,
methods: {},
mixins: {
ModifiedTimestamp: {}
},
relations: {
category: {
type: "belongsTo",
model: "Category",
foreignKey: ""
}
},
strict: false,
validations: []
}]Retrieve one model:
http://0.0.0.0:3000/api/Meta/Category
{
id: "Category",
name: "Category",
properties: {
name: {
type: "String",
required: true
}
},
acls: [],
base: "BaseModel",
idInjection: true,
methods: {},
mixins: {
ModifiedTimestamp: {}
},
relations: {
products: {
type: "hasMany",
model: "Product",
foreignKey: ""
}
},
strict: false,
validations: []
}