# View SQLite records show empty (but actually full)

**URL:** <https://discourse.nodered.org/t/view-sqlite-records-show-empty-but-actually-full/28692>\
**Category:** Dashboard\
**Created:** [21 June 2020 14:51 UTC](https://discourse.nodered.org/t/view-sqlite-records-show-empty-but-actually-full/28692 "2020-06-21T14:51:29Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![EDsteve](https://avatars.discourse-cdn.com/v4/letter/e/51bf81/32.png) [@EDsteve](https://discourse.nodered.org/u/EDsteve)\
**Post date:** [21 June 2020 14:51 UTC](https://discourse.nodered.org/t/view-sqlite-records-show-empty-but-actually-full/28692/1 "2020-06-21T14:51:29Z")

</div>

Hi,

i have problem to display SQLite content on the dashboard.  
It find all the content in the DB and shows it in the debug nodes. But It won't display it on the dashboard. What am i doing wrong here? I already tried several example flows. Like this one:

```auto
[{"id":"4ecdb4d3.e637ec","type":"tab","label":"Flow 4","disabled":false,"info":""},{"id":"640448d2.9babe8","type":"inject","z":"4ecdb4d3.e637ec","name":"show RECORDS","topic":"SELECT * FROM phone ORDER BY TIMESTAMP DESC LIMIT 100","payload":"","payloadType":"date","repeat":"","crontab":"","once":true,"onceDelay":"","x":190,"y":160,"wires":[["bbce3c8a.708ea"]]},{"id":"9adc2560.90bc08","type":"ui_template","z":"4ecdb4d3.e637ec","group":"559d2777.1dd768","name":"UI Table","order":1,"width":"","height":"","format":"<style>\n.table\n</style>\n<div class=\"table\">\n<table style=\"width:100%\">\n <tr>\n <th>TIMESTAMP</th> \n <th>battery</th>\n\n </tr>\n <tr ng-repeat=\"x in msg.payload | limitTo:10\">\n <td>{{msg.payload[$index].TIMESTAMP}}</td>\n <td>{{msg.payload[$index].level}}</td>\n\n </tr>\n</table>\n</div>","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":false,"templateScope":"local","x":700,"y":160,"wires":[["a46d01b4.1a8b3"]]},{"id":"bbce3c8a.708ea","type":"sqlite","z":"4ecdb4d3.e637ec","mydb":"e41aec91.18f5b","sqlquery":"msg.topic","sql":"","name":"","x":430,"y":160,"wires":[["9adc2560.90bc08","c67c7fcf.16708"]]},{"id":"c67c7fcf.16708","type":"debug","z":"4ecdb4d3.e637ec","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":590,"y":100,"wires":[]},{"id":"a46d01b4.1a8b3","type":"debug","z":"4ecdb4d3.e637ec","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":910,"y":160,"wires":[]},{"id":"559d2777.1dd768","type":"ui_group","z":"","name":"Sensors","tab":"d9609e7e.bfb89","order":1,"disp":true,"width":"12","collapse":false},{"id":"e41aec91.18f5b","type":"sqlitedb","z":"","db":"my.db","mode":"RWC"},{"id":"d9609e7e.bfb89","type":"ui_tab","z":"","name":"Home","icon":"dashboard"}]

```

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/e/8eb53639ccfb1c458e784495602b3f408651f29f.png)

P.S.: I am using the RedMobile version of NodeRed

---

<div class="post-metadata">

**Author:** ![Brian5600](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/brian5600/32/94271_2.png) [@Brian5600](https://discourse.nodered.org/u/Brian5600)\
**Post date:** [21 June 2020 18:28 UTC](https://discourse.nodered.org/t/view-sqlite-records-show-empty-but-actually-full/28692/2 "2020-06-21T18:28:17Z")

</div>

Hello ESteve  
What are Your output in a debug node?  
Beste regards  
Brian

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [21 June 2020 18:39 UTC](https://discourse.nodered.org/t/view-sqlite-records-show-empty-but-actually-full/28692/3 "2020-06-21T18:39:37Z")

</div>

Try this

```auto
<style>
.table
</style>
<div class="table">
<table style="width:100%">
  <tr>
    <th>TIMESTAMP</th> 
    <th>SENSOR</th>

  </tr>
  <tr ng-repeat="row in msg.payload | limitTo:2">
   <td ng-repeat="item in row" >{{item}}</td>
 </tr>
</table>
</div>

```

---

<div class="post-metadata">

**Author:** ![EDsteve](https://avatars.discourse-cdn.com/v4/letter/e/51bf81/32.png) [@EDsteve](https://discourse.nodered.org/u/EDsteve)\
**Post date:** [21 June 2020 23:37 UTC](https://discourse.nodered.org/t/view-sqlite-records-show-empty-but-actually-full/28692/4 "2020-06-21T23:37:05Z")

</div>

Thanks you for your answers.

@Brian5600  
Looks like this: ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/a/fa8ddba6f3c2edce9e08dd0fafd16284b698eebc.png)

@zenofmud  
When i use your UI Table. I get this oputput:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/4/4410fe65ec0743ca1e6e39740a27657a66af77d4.png)

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [22 June 2020 09:28 UTC](https://discourse.nodered.org/t/view-sqlite-records-show-empty-but-actually-full/28692/5 "2020-06-22T09:28:41Z")

</div>

This should do it for you

```auto
<style>
.table
</style>
<div class="table">
<table style="width:100%">
  <tr>
    <th>TIMESTAMP</th> 
    <th>SENSOR</th>

  </tr>
  <tr ng-repeat="row in msg.payload | limitTo:2">
   <td>{{row.TIMESTAMP}}</td>
   <td>{{row.SENSOR}}</td>
 </tr>
</table>
</div>

```

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [22 June 2020 09:33 UTC](https://discourse.nodered.org/t/view-sqlite-records-show-empty-but-actually-full/28692/6 "2020-06-22T09:33:52Z")

</div>

really ? in the debug it looks like `msg.payload.rows` is the array, not msg.payload

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [22 June 2020 09:45 UTC](https://discourse.nodered.org/t/view-sqlite-records-show-empty-but-actually-full/28692/7 "2020-06-22T09:45:39Z")

</div>

@dceejay I think you are right. Not having the schema, I assumed (bad idea) that the rows would be returned to msg.payload.

@Brian5600 What is the schema of your database?  
I would add a `change` node before the `ui-table` node to move msg.payload.rows to msg.payload

---

<div class="post-metadata">

**Author:** ![Brian5600](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/brian5600/32/94271_2.png) [@Brian5600](https://discourse.nodered.org/u/Brian5600)\
**Post date:** [22 June 2020 11:11 UTC](https://discourse.nodered.org/t/view-sqlite-records-show-empty-but-actually-full/28692/8 "2020-06-22T11:11:45Z")

</div>

> [@zenofmud](#):
>
> ` <td>{{row.TIMESTAMP}}</td>`

I think You miss an s in rows.TIMESTAMP

> [@EDsteve](#):
>
> `<td>{{msg.payload[$index].TIMESTAMP}}</td>`

So this might be  
msg.payload.rows[$index].TIMESTAMP for data  
I made a solution like this some years ago. I might find it later. But I am on work right now. I cant remember how to use $index  
Or @zenofmud solution with moving the rows from rows to payload. But it might not be so nice, if it mix up with or overwrite other data in payload.

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [22 June 2020 11:17 UTC](https://discourse.nodered.org/t/view-sqlite-records-show-empty-but-actually-full/28692/9 "2020-06-22T11:17:00Z")

</div>

Or maybe change the ng-repeat from `row in msg.payload ` to `row in msg.payload.rows`

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [22 June 2020 11:18 UTC](https://discourse.nodered.org/t/view-sqlite-records-show-empty-but-actually-full/28692/10 "2020-06-22T11:18:26Z")

</div>

> [@Brian5600](#):
>
> > [@zenofmud](#):
> >
> > `<td>{{row.TIMESTAMP}}</td>`
> 
> I think You miss an s in rows.TIMESTAMP

Nope, the 'row' in this case is an index into the payload. I could have use 'x' or 'foo' as long as it matched the name used in the nr-repeat in the \<tr...\>  
If you used `<tr ng-repeat="foo in msg.payload | limitTo:2">` the the \<td... would be  
`<td>{{foo.TIMESTAMP}}</td>`

As for msg.payload, if he needs to keep the entire contents, in the `change` node, he could set another msg property - say msg.orig\_payload to it and after the ui-table node, have another `change` node to move it back to msg.payload

---

<div class="post-metadata">

**Author:** ![Brian5600](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/brian5600/32/94271_2.png) [@Brian5600](https://discourse.nodered.org/u/Brian5600)\
**Post date:** [22 June 2020 11:19 UTC](https://discourse.nodered.org/t/view-sqlite-records-show-empty-but-actually-full/28692/11 "2020-06-22T11:19:27Z")

</div>

Yes, it is close now, Pete Scargill made some things I used back in 2017 I think it was.

---

<div class="post-metadata">

**Author:** ![Brian5600](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/brian5600/32/94271_2.png) [@Brian5600](https://discourse.nodered.org/u/Brian5600)\
**Post date:** [22 June 2020 11:49 UTC](https://discourse.nodered.org/t/view-sqlite-records-show-empty-but-actually-full/28692/12 "2020-06-22T11:49:25Z")

</div>

Oh, this way, thank You,  
But then @dceejay is fully right with his answer 😊

And yes about moving around payload, but still dont move more than nescessary. It only make confusion bigger, and search for errors more difficult.

> [@zenofmud](#):
>
> If you used `<tr ng-repeat="foo in msg.payload | limitTo:2">` the the \<td... would be  
> `<td>{{foo.TIMESTAMP}}</td>`

Become `<tr ng-repeat="foo in msg.payload.rows | limitTo:2">`

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [22 July 2020 11:49 UTC](https://discourse.nodered.org/t/view-sqlite-records-show-empty-but-actually-full/28692/13 "2020-07-22T11:49:35Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
