node.js - Order by two tables in node orm2 with an order by between them -


i have definition of table categories node-orm2:

models.categories = db.define("categories", {    id: {type: 'serial', key: true},    name: {type: 'text', required: true, unique:true} }, {   methods: {},   validations: {} }); 

and definition of table products, related categories:

models.products = db.define("products", {    id: {type: 'serial', key: true},    description: {type: 'text', required: true} }, {   methods: {},   validations: {} });  models.products.hasone("category", models.categories, {required: true, reverse: "products"}); 

i've tried categories , related products make report control break on category name , product description, this:

select * categories cat,products prod cat.id = prod.category_id order cat.name, prod.description; 

but couldn't find clear way make 'order by'. i've defined async procedure categories, , after that, each category, products ordered. of course, slow. how can single query ?


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -