TypeScript ORM
  • Introduction
  • Installation
  • Base Classes
  • Tables and Views
    • Select
    • Insert/Update
    • Delete
    • toQuery
    • toDataSet
  • Stored Procedures
    • Execute
    • toProcedure
    • toDataSet
Powered by GitBook
On this page
  1. Tables and Views

toQuery

PreviousDeleteNexttoDataSet

Last updated 1 year ago

Use the toQuery method to transform an entity ORM object into a object.

TableQuery

The toQuery transform allows the functionality of the table query to be used with ORM objects.

The example below transforms the Categories ORM query for CategoryName into a table query. It then joins Categories with Products adding ProductName to the list of selected fields. Last, it executes the query directly against the Northwind data source.

...

let query = Categories.select(CategoriesField.CategoryName).toQuery();

query.field("ProductName")
    .join("Products", "CategoryId").on("Categories", "CategoryId");

const table: IWireDataTable = await Northwind.execAsync(query);

// print the first row to the console log
console.log(table.select().first());

// log-> { CategoryName: "Dairy Products", ProductName: "Queso Cabrales" }
WireBootstrap TableQuery