工場の女の子のインスタンスを作成します。これは私のデータは、データベースのように見えるものである別の工場の女の子のインスタンスを作成するための内部
{
"id": 4,
"name": "New Sad",
"open": true,
"description": "The happiest place on earth!",
"gps": "133.232, 121.021",
"regionId": 1,
"location": "{\"regionName\":\"Bishop\",\"regionId\":1}",
"updatedAt": "2017-12-06T05:24:44.683Z",
"createdAt": "2017-12-06T05:24:44.683Z"
}
私はjsonb
列をHAVA、これは、クエリその理由を検索するための場ですべての親テーブルですは私がfactory.assocを使用していない理由です。私はassoc
を使用してすぐに作成するものを参照することはできません。
私の工場-女の子を定義するには、私はちょうどこの操作を行うと考えていた:
module.exports = async factory => {
const region = await factory.create('region');
const area = factory.define('area', Area,() => {
return {
name: factory.chance('first'),
open: true,
description: factory.chance('sentence', {words: 5}),
gps: '122.123, 123.342',
regionId: factory.assoc('region', 'id'),
location: JSON.stringify({
regionName: region.dataValues.name,
regionId: region.dataValues.id,
}),
};
});
return area;
};
エラーメッセージ:それは私がそれを試みた最初の時間を動作しませんでした
(node:49078) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): Error: Invalid factory 'region requested (node:49078) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.