We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
file ./products.hooks.js
function include() { return function (hook) { const productPrice = hook.app.service('product-prices').Model; const currencies = hook.app.service('currencies').Model; const edizm = hook.app.service('edizm').Model; const pricesShema = { model: productPrice, attributes: ['price', 'price_promo', 'price_card','publish'], include: [ { model: currencies, attributes: ['title', 'socr'] }, ] }; const edizmShema = { model: edizm, attributes: ['title', 'detail'] }; const association = { include: [edizmShema,pricesShema] }; hook.params.sequelize = Object.assign(association, { raw: false }); return Promise.resolve(hook); } }
file ./product-prices.model.js
module.exports = function (app) { const sequelizeClient = app.get('sequelizeClient'); const productPrices = sequelizeClient.define('productPrices', { ........ }, { defaultScope: { where: { publish: true } }, .......... }); ........................... return productPrices; };
If you run the query http://localhost:3030/products/6 then we get
{ "name": "NotFound", "message": "No record found for id '6'", "code": 404, "className": "not-found", "errors": {} }
If the file ./product-prices.model.js is removed
where: { publish: true }
run the query http://localhost:3030/products/6 then we get
{ "id": 6, "title": "Milk", "count": "0.930", "edizm_id": 7, "product_tms_id": 1, "product_category_id": 3, "products_param_id": 0, "image": "milk_6.png", "detail": "", "sostav": "", "created_at": null, "updated_at": "2016-05-26T06:39:24.000Z", "productPrices": [] }
How to make that and in the first case the result with an empty value in the association be displayed.
Thanks for the help.
The text was updated successfully, but these errors were encountered:
Found the answer himself required: false,
const pricesShema = { model: productPrice, attributes: ['price', 'price_promo', 'price_card'], required: false, where: { publish: 1 }, include: [ { model: currencies, attributes: ['title', 'socr'], }, ] };
Sorry, something went wrong.
No branches or pull requests
Steps to reproduce
file ./products.hooks.js
file ./product-prices.model.js
If you run the query http://localhost:3030/products/6 then we get
If the file ./product-prices.model.js is removed
run the query http://localhost:3030/products/6 then we get
How to make that and in the first case the result with an empty value in the association be displayed.
Thanks for the help.
The text was updated successfully, but these errors were encountered: