2016-06-11 50 views
0

使用貓鼬Node.js的我犯了一個基地實體是子分類到用戶實體和實體建造在客戶端繼承,並且都到家庭實體的引用,我的問題是使用微風MetadataHelper我如何定義,一個家庭可以擁有navigationProperties數組,它可以是一個用戶實體。總之,我失去了面向對象,那麼是否有一種方法可以在客戶端使用Breeze構造多態支持繼承,這正是我所想到的。使用微風元幫手如何通過手

var addFamilyItemType =(): any => { 
      var entityType = { 
       name: this.entityNames.Family, 
       dataProperties: { 
        id: {type: DT.MongoObjectId}, 
        name: {type: DT.String, required: true, max: 50} 
       }, 

       navigationProperties: { 
       //this is where i want one navigation since they are a subclass 
       // members: {type: [], hasMany: true} 
        users: {type: [this.entityNames.User], hasMany: true}, 
        people: {type: [this.entityNames.Person], hasMany: true} 
       } 
      }; 

      helper.addTypeToStore(store, entityType); 
      return entityType; 
     }; 

    var addUserItemType =(): any => { 
      var entityType = { 
       name: this.entityNames.User, 
       dataProperties: { 
        id: {type: DT.MongoObjectId}, 
        email: {type: DT.String, required: true, max: 50}, 
        username: {type: DT.String, required: true, max: 20}, 
        password: {type: DT.String, 'default': ''} 
       }, 
       navigationProperties: { 
        family: { 
         entityTypeName: this.entityNames.Family, 
         associationName: 'User_Family', 
         foreignKeyNames: ['familyId'] 
        } 
       } 
      }; 

      helper.addTypeToStore(store, entityType); 
      return entityType; 
     }; 

var addPersonItemType =(): any => { 
      var entityType = { 
       name: this.entityNames.Person, 
       dataProperties: { 
        id: {type: DT.MongoObjectId}, 
        email: {type: DT.String, max: 50}, 
        profileImageURL: {type: DT.String,'default':''}      
       }, 
       navigationProperties: { 
        family: { 
         entityTypeName: this.entityNames.Family, 
         associationName: 'Person_Family', 
         foreignKeyNames: ['familyId'] 
        } 
       } 
      }; 

      helper.addTypeToStore(store, entityType); 
      return entityType; 
     }; 

回答

0

我找到了解決辦法是添加一個名爲成員對FamilyModel對象調用registerEntityTypeCtor時將返回兩個數組用戶和其他人的工會吸氣財產,我想微風繼承支持開箱即用的。

var metadataStore = this.metadata.createMetadataStore(); 
var registerType = metadataStore.registerEntityTypeCtor.bind(metadataStore); 

registerType(this.metadata.entityNames.Family, FamilyModel);