Skip to main content
1-Visitor
Nov 24, 2017 7:15 AM UTC
Solved

delete values from stream

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..

DarrylAnswer
1-Visitor
Nov 24, 2017 9:21 AM UTC

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 });

}

11 replies

1-Visitor
Nov 24, 2017 7:54 AM UTC

Hi Darryl, Stream or ValueStream?

Translate
Darryl1-VisitorAuthor
1-Visitor
Nov 24, 2017 8:00 AM UTC

Hi

Stream.

Translate
1-Visitor
Nov 24, 2017 8:15 AM UTC

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.

Translate