回送插入模型及其关系数据

时间:2018-08-30 06:09:58

标签: loopbackjs

我正在尝试插入模型(oc_product)及其关系(oc_product_description)数据。

正在插入模型,但没有插入关系数据。我没有收到任何错误消息。

我在oc_product中的关系配置。

"relations": {
    "ocProductDescriptions": {
        "type": "hasOne",
        "model": "oc_product_description",
        "foreignKey": "product_id",
        "options": {
            "nestRemoting": true,
            "validate": true,
            "forceId": false
        }
    },
}, 

oc_product_description.js product_id字段配置

"product_id": {
    "type": "Number",
    "id": true,
    "generated": true,
    "length": null,
    "precision": 10,
    "scale": 0,
    "mysql": {
        "columnName": "product_id",
        "dataType": "int",
        "dataLength": null,
        "dataPrecision": 10,
        "dataScale": 0,
        "nullable": "N"
    }
},

创建实例的代码

app.models.oc_product.create(ocProduct, function(err, instance) {
    if (err) {
      console.log(err);
    } else {
      console.log('created');
      console.log(instance);
    }
});

记录的实例

created
    { model: '6932849427639',
    viewed: 0,
    isbn: '',
    image: '/var/www/3.0.2.0-OpenCart/products/3/npten-a18-lg.jpg',
    shipping: 1,
    manufacturer_id: 8,
    sku: 'SKU',
    upc: 'UPC',
    ean: 'EAn',
    jan: '',
    mpn: 'A18',
    price: 16.1,
    length: 99,
    width: 98,
    height: 97,
    location: 'London, Uk',
    quantity: 100,
    minimum: 1,
    subtract: 1,
    weight: 0.3,
    stock_status_id: 7,
    points: 0,
    sort_order: 3,
    weight_class_id: 1,
    length_class_id: 1,
    status: 1,
    tax_class_id: 9,
    date_available: 2018-08-30T05:55:05.000Z,
    date_added: 2018-08-30T05:55:05.000Z,
    date_modified: 2018-08-30T05:55:05.000Z,
    ocProductDescription:
    { language_id: '1',
        name: 'Tenda A18 AC1200 Dual-Band WiFi Repeater',
        description: 'A18 is an AC1200 dual-band WiFi repeater dedicated for two-storey houses, villas, and multi-room houses with an area over 120 square meters. It offers up to 300 Mbps data rate on 11n band and 867 Mbps data rate on 11ac band. With two external omni-directional antennas, A18 can provide larger WiFi coverage, as well as extreme fast data rate, satisfying applications such as playback of 1080P HD videos, massively multiplayer online games, and high-speed download. With the upgrade Setup Wizard, it only takes you three steps to configure your repeater, which is easy to use. A18 also works better with other brands\' WiFi router available on the market. For whole home WiFi coverage, A18 is your best choice.<br/><br/><b>Gigabit WiFi Repeater Works Well with Optical Routers</b><br/><b>AC1200 Dual Band WiFi Repeater Tenda A18</b><br/><br/><b>Works Well with Optical Routers for Strong Wall Penetration Capacity on 5 GHz Band</b><br/>Ordinary 11AC routers performs poorly on wall penetration on 5 GHz band. With A18 to repeat 5 GHz WiFi network, data transmission rate on 5 GHz band can be up to 867 Mbps, giving a full play to your 100 Mbps optical broadband. By resolving the weakness of WiFi coverage on 5 GHz band, A18 brings you with fast internet experience at home.<br/><br/><b>Scan Quality Channel Automatically for Stable, Reliable and Fast Internet Experience</b><br/>Equipped with high quality PCB dual band antennas, the radio frequency distance between antennas of A18 has been improved to um. Each antenna provides both 2.4 GHz and 5 GHz WiFi networks, and extends WiFi networks both on 2.4 GHz and 5 GHz bands . A18 can automatically select high quality channel for you when signal fluctuates, and keeps your devices online even in the move by switching to the network with stronger signals automatically.<br/><br/><b>Visual Signal LED Guides You to Find the Best Position</b><br/>Guided by the color of Signal LED, you can easily find the best position for your repeater according to your actual network environment. Blue indicates good connection , and red indicates bad connection.<br/><br/><b>Configure Your Repeater via Smart Phones/Tablets</b><br/>Simplicity is practical. You can configure your repeater via smart phones or Tablets<br/><br/><b>Elegant and Compact Appearance</b><br/>Featured with a small size, it is easy for you to plug A18 into your electrical outlet.<br/><br/><b>One More 100 Mbps LAN port for Wired Extension</b><br/>Signal is full but the internet is still inaccessible? Want to watch online TV programs on a LCD TV with LAN port but without WiFi adapter? <br/>A18 can relieve you from these two painstaking. By connecting the Ethernet cable from your router to the LAN port of A18, you can extend your existing WiFi network in wired manner. To watch online TV programs, you just need to connect the LAN port of A18 that has extended successfully to the LAN port of your LCD TV.<br/><br/><b>More functions</b><br/>Hide SSID, Extend your existing WiFi network via WPS button, Mix WPA/WPA2 encryption mode<br/>- Hide SSID<br/>- WPS Function<br/>- Encryption Mode<br/><br/><b>Port</b><br/>1 x 10/100 Mbps RJ45<br/><br/><b>Buttons</b><br/>Reset<br/>WPS<br/><br/><b>LED</b><br/>1 x Signal LED<br/>1 x WPS LED<br/>1 x Power LED<br/><br/><b>Power Supply</b><br/>9V 0.8A, built-in<br/><br/><b>Plug Types</b><br/>National Standard, US Standard, European Standard, UK Standard, Brazil Standard<br/><br/><b>Power Consumption</b><br/>No-load: 2.8W, Full-load: 5.2W<br/><br/><b>Dimension</b><br/>80 x 58 x 48 mm<br/><br/><b>Standard & Protocol</b><br/>IEEE 802.11a, IEEE 802.11n, and IEEE 802.11ac wave2 on 5 GHz<br/>IEEE 802.11b, IEEE 802.11g, and IEEE 802.11n on 2.4 GHz<br/><br/><b>Data Rate</b><br/>802.11b: 11 Mbps<br/>802.11g: 54 Mbps<br/>802.11n: 300 Mbps<br/>802.11ac: 867 Mbps<br/><br/><b>Frequency Band</b><br/>11n: 2.412-2.484 GHz<br/>11ac: 5.15-5.25 GHz<br/><br/><b>Transmit Power</b><br/>2.4 GHz: 16dBm<br/>5 GHz: 12dBm<br/><br/><b>RSSI</b><br/>2.4 GHz:<br/>11b-1M:-97dBm<br/>11g-54M:-76dBm<br/>11n-20M-MCS7:-74dBm<br/>11n-40M-MCS7:-72dBm<br/>5 GHz:<br/>11a-6M:-95dBm<br/>11n-20M-MCS7:-74dBm<br/>11n-40M-MCS7:-72dBm<br/>11ac-80M-MCS9:-63dBm<br/><br/><b>Antenna</b><br/>2 x External 2dBi dual-band omni-directional antenna (non-detachable)<br/><br/><b>Channel</b><br/>11n: 20/40MHz by default<br/>11ac: 80MHz by default<br/><br/><b>Operating Mode</b><br/>Repeater Mode<br/>AP Mode<br/><br/><b>Wireless Security</b><br/>Default encryption mode: Mix WPA-PSK/WPA2-PSK<br/>WPA algorithm: TKIP<br/><br/><b>DHCP Server</b><br/>Supported<br/><br/><b>System Tool</b><br/>Firmware upgrade, Restore factory settings, Login password, and Reboot<br/><br/><b>Temperature</b><br/>Operating temperature:0ºC~40ºC<br/>Storage temperature:-40ºC~70&#8451;<br/>HumidityOperating humidity:(10  90)% RH, non-condensing<br/>Storage temperature:5%~90%RH, non-condensing<br/><br/><b>Package Content</b><br/>1 x AC1200 Dual Band WiFi Repeater<br/>1 x Quick Installation Guide',
        tag: 'tag',
        meta_title: 'meta tag title',
        meta_description: 'Meta Tag Description',
        meta_keyword: 'Meta Tag Keywords' },
    product_id: 4 }

1 个答案:

答案 0 :(得分:0)

正如我发现的那样,目前是不可能的。