Hi,
I use the version 3.0.0rc2.
I made a projection in continuous mode with c# .net. But there is an error, it miss double quotes in the “if” statement.
Even with the error, my projection is saved, when I launch the server for the first time, the projection is starting, and i can do nothing except disable it.
I can have the access to the editor, but i can’t modify any chars.
How can I remove or update it, please ?
jen20
June 16, 2014, 8:02am
2
Hi Catherine,
You can delete it in one of three ways:
- using the web UI
- using the Delete method on the ProjectionsManager class in the C# client API (https://github.com/EventStore/EventStore/blob/dev/src/EventStore/EventStore.ClientAPI/ProjectionsManager.cs#L367 )
- making an HTTP request using the DELETE method to <event store base URI>/projection/</projection name>.
You can also update the source if you made an error initially, see the Update method on the Client API, or by issuing a PUT to <event store base URI>/projection/{0}/query?type=JS (or via the UI, you’ll need to navigate to the projection and then click the Edit button).
Regards,
James
Thanks to reply.
I tried using the web UI, and update the projection with the Edit button but i can’t update, or write in the projection to correct the error.
I tried with the Delete and Update methods on the ProjectionsManager class in c# client API, and this doesn’t work.
And I don’t know how to make an HTTP request.
Regards,
Catherine Santos
jen20
June 16, 2014, 9:07am
4
Can you paste the code you’re using with the API, there’s no reason this shouldn’t work.
That’s the code for updating the projection. I make a loop to be sure it is trying several times. The projection has the status “stopping”.
ProjectionsManager pm = new ProjectionsManager(new ConsoleLogger(), new IPEndPoint(IPAddress.Parse(“127.0.0.1”), 2113));
bool update = true;
int i = 0;
string query = @"fromStream(‘Reservations’)
.when({
$init: function () {
return { body: ‘’, }; // initial state
},
ReservationEvent: function(s, e) {
var month = 0;
if(e.body.NewReservation !== null)
{
month = e.body.NewReservation.StartDate.split('-')[1];
if(month == 6 && e.body.NewReservation.IdFirm =='1dd70dbe-1913-4c8f-9435-01f41ed156a7')
{
s.body += e.bodyRaw;
}
}
else
{
month = e.body.OldReservation.StartDate.split('-')[1];
if(month == 6 && e.body.OldReservation.IdFirm =='1dd70dbe-1913-4c8f-9435-01f41ed156a7')
{
s.body += e.bodyRaw;
}
}
return s;
}
})";
do
{
try
{
pm.UpdateQuery(name, query, user);
update = true;
}
catch (Exception)
{
update = false;
Console.WriteLine(i++);
}
} while (!update);
``
And that the code for deleting.
bool deleted = true;
int i = 0;
do
{
try
{
pm.Delete(name, user);
deleted = true;
}
catch (Exception)
{
deleted = false;
Console.WriteLine(i++);
}
} while (!deleted);
``
Hi,
Someone knows how can i fix this problem please ?
Thanks.