mirror of
https://github.com/amark/gun.git
synced 2025-05-19 13:26:48 +00:00
32 lines
1.5 KiB
Plaintext
32 lines
1.5 KiB
Plaintext
OrderID CustomerID OrderDate
|
|
10308 2 1996-09-18
|
|
10309 37 1996-09-19
|
|
10310 77 1996-09-20
|
|
|
|
CustomerID CustomerName ContactName Country
|
|
1 Alfreds Futterkiste Maria Anders Germany
|
|
2 Ana Trujillo Emparedados y helados Ana Trujillo Mexico
|
|
3 Antonio Moreno Taquería Antonio Moreno Mexico
|
|
|
|
{
|
|
Orders: {
|
|
10308: {OrderID: 10308, Customer: {#: 2}, OrderDate: '1996-09-18' }
|
|
10309: {OrderID: 10309, Customer: {#: 3}, OrderDate: '1996-09-19' }
|
|
10310: {OrderID: 10310, Customer: {#: 77}, OrderDate: '1996-09-20' }
|
|
}
|
|
Customers: {
|
|
1: {CustomerID: 1, CustomerName: "Alfreds Futterkiste", ContactName: "Maria Anders", Country: "Germany" }
|
|
2: {CustomerID: 2, CustomerName: "Ana Trujillo Emparedados y helados", ContactName: "Ana Trujillo", Country: "Mexico" }
|
|
3: {CustomerID: 3, CustomerName: "Antonio Moreno Taquería", ContactName: "Antonio Moreno", Country: "Mexico" }
|
|
}
|
|
}
|
|
|
|
gun.sql().select('OrderID', 'Customers.CustomerName', 'OrderDate').from('Orders').join('Cutomers').on('Customer'); // ignore /\s*=/ig and beyond
|
|
|
|
^compatibility. // select should accept 1 string that is /\,\s*/ig separated, arguments of strings, an array of strings.
|
|
// unfortunately for compatibility mode, you might have to match&strip any string that has a '.' in it with a subsequent .join/.on
|
|
better:
|
|
|
|
gun.sql().select('OrderID', OrderDate').from('Orders').join.on('Customer').select('CustomerName').run().get(function(row){
|
|
console.log(row); // {OrderID: 10308, CustomerName: "Ana Trujillo Emparedados y helados", OrderDate: "1996-09-18" }
|
|
}); |