私はユーザのプロファイルを表すテーブルを持っています。このプロファイルは他のプロファイルに従うことができます。ここでループバック: "hasMany"タイプの関係テーブルにデータを追加
は私profil.jsonの一部である
"relations": {
"followers": {
"type": "hasMany",
"model": "Profil",
"foreignKey": "publisherId",
"keyThrough": "subscriberId",
"through": "Subscribing"
},
"subscribings": {
"type": "hasMany",
"model": "Profil",
"foreignKey": "subscriberId",
"keyThrough": "publisherId",
"through": "Subscribing"
},
まあこれは正常に動作しますが、今はプロフィールが登録された日付を知られたく。
だから私は取得する可能性を持ちながら、今、私はこのprofilsのデータを照会できるようにしたいと思い
{
"name": "Subscribing",
"base": "PersistedModel",
"idInjection": true,
"options": {
"validateUpsert": true
},
"properties": {
"subscriptionDate": {
"type": "date",
"required": true,
"default": "$now"
}
},
"validations": [],
"relations": {
"subscriber": {
"type": "belongsTo",
"model": "Profil",
"as": "subscriber"
},
"publisher": {
"type": "belongsTo",
"model": "Profil",
"as": "publisher"
}
},
"acls": [],
"methods": {}
}
日付を追加するためにsubscribing.json関連テーブルを更新同じ時間内にサブスクリプションの日付。理想的には、関係表を非公開にしておきます。 ありがとう
ありがとう、私はそれを試し、あなたにいくつかのフィードバックをします。ちょうど私にそれを消化する時間を与えてください:) – chd