@@ -7,42 +7,36 @@ module.exports = function (Meta) {
77 * Helper method for format the type of the properties
88 */
99 function formatProperties ( properties ) {
10- // for (var key in properties) {
11- // var type = properties[key].type.toString().toLowerCase().substr('function '.length);
12- // type = type.substr(0, type.indexOf('('));
13- // properties[key].type = type;
14- // }
10+ for ( var key in properties ) {
11+ var type = properties [ key ] . type . toString ( ) . toLowerCase ( ) . substr ( 'function ' . length ) ;
12+ type = type . substr ( 0 , type . indexOf ( '(' ) ) ;
13+ properties [ key ] . propertyType = type ;
14+ }
1515 return properties ;
1616 }
1717
18- /**
19- * Get the definition of the model
20- */
21- function getModelDefinition ( modelName ) {
22- return Meta . app . models [ modelName ] . definition ;
23- }
2418
2519 /**
2620 * Get the definition of a model and format the result in a way that's similar to a LoopBack model definition file
2721 */
2822 function getModelInfo ( modelName ) {
2923
30- // Get the model definition
31- var definition = getModelDefinition ( modelName ) ;
24+ // Get the model
25+ var model = Meta . app . models [ modelName ] ;
3226
3327 // Create the base return object
3428 var result = {
35- id : definition . name ,
36- name : definition . name ,
37- properties : formatProperties ( definition . properties )
29+ id : model . definition . name ,
30+ name : model . definition . name ,
31+ properties : formatProperties ( model . definition . properties )
3832 } ;
3933
4034 // Get the following keys from the settings object, if they are set
4135 var keys = [ 'description' , 'plural' , 'base' , 'idInjection' , 'persistUndefinedAsNull' , 'strict' , 'hidden' ,
4236 'validations' , 'relations' , 'acls' , 'methods' , 'mixins'
4337 ] ;
4438 keys . forEach ( function ( key ) {
45- result [ key ] = _ . get ( definition . settings , key ) ;
39+ result [ key ] = _ . get ( model . definition . settings , key ) ;
4640 } ) ;
4741 return result ;
4842 }
0 commit comments