Skip to content
This repository has been archived by the owner on Nov 2, 2020. It is now read-only.

modules.api.sql.select and the order of fields #1

Open
senikk opened this issue Mar 19, 2016 · 1 comment
Open

modules.api.sql.select and the order of fields #1

senikk opened this issue Mar 19, 2016 · 1 comment
Labels

Comments

@senikk
Copy link

senikk commented Mar 19, 2016

I'm concerned about the need for the fields to be ordered just like they exists in the blockchain.db and if you join with system table like often used in the examples like "transactions" if Lisk team decide to add a new field in "transactions" every dapps which updates the SDK breaks.

@TheGoldenEye
Copy link

Using the "fields" option you can specify the columns and their order you need.
Example:

modules.api.sql.select(
  {
  table: "transactions",
  alias: "t",
  fields: [{"t.senderId": "senderId", "t.senderPublicKey": "senderPublicKey", "t.recipientId": "recipientId", "t.id":"transactionId"}],
  condition: 
    {
    recipientId: query.recipientId,
    type: self.type
    },
  join: [
    {
    type: 'left outer',
    table: 'asset_messages',
    alias: "tm",
    on: {"t.id": "tm.transactionId"}
    }]
  }, ['senderId', 'senderPublicKey', 'recipientId', 'transactionId'], 
  function (err, transactions) { ...}

@karmacoma karmacoma self-assigned this Jun 19, 2016
@karmacoma karmacoma removed their assignment Jan 3, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants