Skip to main content
1-Visitor
November 24, 2017
Solved

delete values from stream

  • November 24, 2017
  • 1 reply
  • 5046 views

Hello Experts

I need to delete a range of data from a Stream.

How do I go about doing this? It is only for one things values though.

Help..

Best answer by Darryl

Excellent. Here is the working code:

var params = {

oldestFirst: undefined /* BOOLEAN */,

maxItems: undefined /* NUMBER */,

sourceTags: undefined /* TAGS */,

endDate: endDate /* DATETIME */,

query: undefined /* QUERY */,

source: source /* STRING */,

startDate: startDate /* DATETIME */,

tags: undefined /* TAGS */

};

// result: INFOTABLE

var result = Things["ApexReadingsStream"].QueryStreamEntriesWithData(params);

var stream = Things["ApexReadingsStream"];

for each(entry in result.rows) {

  stream.DeleteStreamEntry({ streamEntryId: entry.id });

}

1 reply

1-Visitor
November 24, 2017

Hi Darryl, Stream or ValueStream?

Darryl1-VisitorAuthor
1-Visitor
November 24, 2017

Hi

Stream.

1-Visitor
November 24, 2017

If you have to delete all the entries for a given period, you are lucky, you just need to use PurgeStreamEntries service. If you need to delete entries with a query condition, then you aren't that lucky, you have to query first and then execute one by one the service DeleteStreamEntry. For the second option, if you have to delete a lot of entries you will start having problems, well at least with Neo4J, we have a special code in order to delete entries in batch, now we are on PostgreSQL and we didn't had time to test if this problem that we had on Neo4J still persist on PostgreSQL...

For sure we need better services in order to delete Stream Entries out of the box.