cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

delete values from stream

SOLVED
Participant

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

1 ACCEPTED SOLUTION

Accepted Solutions

Re: delete values from stream

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

}

View solution in original post

11 REPLIES 11

Re: delete values from stream

Hi Darryl, Stream or ValueStream?

Re: delete values from stream

Hi

Stream.

Re: delete values from stream

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.

Re: delete values from stream

Thanks Carles

Ya I am using Postgres. How do I put the multiple stream entry ID's into the form? Should I be separating them by comma?

Re: delete values from stream

Which form the mashup? the composer one?

Better you go with a custom service which accepts as imput stream entries, and loops on all the given entries and calls the DeleteStreamEntry, something like:

var stream = Things["StreamName"];

for each(entry in entries.rows) {

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

}

Re: delete values from stream

Tx Carles

That makes sense, but how would i tell it just just do a specific range? by id or by date?

Re: delete values from stream

I don't understand your question

Re: delete values from stream

i want to be able to specify the source, startDate and endDate as inputs for the service and then run the loop using those inputs.

Re: delete values from stream

Just use QueryStreamEntries service and give the result of this QueryStreamEntries to the custom DeleteStreamEntries that I've pointed out.