2017-10-04 6 views
1

に参加し、私はこのモデルを始めた:私はまたループバッククエリがループバックで

"relations": { 
    "causale_fk": { 
     "type": "hasOne", 
     "model": "causali", 
     "foreignKey": "causale_id", 
     "options": { 
     "nestRemoting": true 
     } 
    }, 
    "conto_fk": { 
     "type": "hasOne", 
     "model": "conti", 
     "foreignKey": "conto_id", 
     "options": { 
     "nestRemoting": true 
     } 
    } 
    }, 

ます:

[ 
    { 
    "mov_id": 0, 
    "mov_tipo": "string", 
    "mov_valore": 0, 
    "mov_causale_fk": 0, 
    "mov_conto_fk": 0, 
    "mov_data": "2017-10-04T09:02:19.620Z", 
    "mov_note": "string", 
    "mov_utente_fk": 0, 
    "mov_aggiunta": "2017-10-04T09:02:19.620Z" 
    } 
] 

その後、私は、MySQLデータベースに2つの外部キーに対応する2つの関係を追加しましたあたかもJOINでクエリを作成したかのように、それらのモデルのフィールドを見るのが好きです。 可能ですか?

答えて

0

私は範囲で解決しました。

これはモデルです:

{ 
    "name": "movimenti", 
    "plural": "movimenti", 
    "base": "PersistedModel", 
    "idInjection": true, 
    "options": { 
    "validateUpsert": true 
    }, 
    "scope": { 
    "include": [ 
     "causale_fk", 
     "conto_fk" 
    ] 
    }, 
    "properties": { 
    "mov_id": { 
     "type": "number", 
     "id": true, 
     "required": true 
    }, 
    "mov_valore": { 
     "type": "number", 
     "required": true 
    } 
    }, 
    "validations": [], 
    "relations": { 
    "causale_fk": { 
     "type": "hasOne", 
     "model": "causali", 
     "foreignKey": "causale_id" 
    }, 
    "conto_fk": { 
     "type": "hasOne", 
     "model": "conti", 
     "foreignKey": "conto_id", 
     "include": "conti" 
    } 
    }, 
    "acls": [], 
    "methods": {} 
} 

さようなら!

0

フィルタにオプションを追加することができます。設定する必要があるオプションは、includeです。詳細については、​​を確認してください。

これはあなたの特定のニーズのための例です:

{ 
Model.find({include:['causale_fk','conto_fk']}, function(){}); 
} 
関連する問題