Setting $maxCount: 1 on projection doesn't seem to work.

I use http api to set $maxCount on projection

curl -i -d @metadata.json http://eventstore-1.local:2113/streams/my-stream/metadata --user admin:changeit -H “Content-Type:application/json” -H “ES-EventId: C322E299-CB73-4B47-97C5-5054F9207”

where metadata.json is

{

“$maxCount”: 1

}

after that I send

curl -i -H “Accept:application/json” “http://eventstore-1.local:2113/streams/my-stream/metadata

and get response

[

{

“eventId”: “7c314750-05e1-439f-b2eb-f5b0e019be72”,

“eventType”: “$metadata”,

“data”: {

“$maxCount”: 1

}

}

]

However events from my-stream are not being deleted.

Please help.

"However events from my-stream are not being deleted."

How are you measuring this?

I use stream browser in Web UI

beware caching, what does curl give you?

curl -i -H “Accept:application/json” “http://eventstore-1.local:2113/streams/my-stream” --user admin:changeit

gives me a lot of events

Herewith my reproduction steps, although it appears the same as yours, just check the last output of curl, as it gives us additional information which might be helpful in debugging.

curl -i http://localhost:2113/streams/a_test_stream -H “accept:application/json” -u admin:changeit
HTTP/1.1 404 Not Found

``

Write 2 Events

curl -i http://localhost:2113/streams/a_test_stream -H “accept:application/json” -u admin:changeit
HTTP/1.1 200 OK
{

“entries”: [
{
“title”: “1@a_test_stream”,
“id”: “http://localhost:2113/streams/a_test_stream/1”,
“updated”: “2016-02-08T11:00:51.097326Z”,
“author”: {
“name”: “EventStore”
},
“summary”: “eventType”,
“links”: [
{
“uri”: “http://localhost:2113/streams/a_test_stream/1”,
“relation”: “edit”
},
{
“uri”: “http://localhost:2113/streams/a_test_stream/1”,
“relation”: “alternate”
}
]
},
{
“title”: “0@a_test_stream”,
“id”: “http://localhost:2113/streams/a_test_stream/0”,
“updated”: “2016-02-08T11:00:49.231723Z”,
“author”: {
“name”: “EventStore”
},
“summary”: “eventType”,
“links”: [
{
“uri”: “http://localhost:2113/streams/a_test_stream/0”,
“relation”: “edit”
},
{
“uri”: “http://localhost:2113/streams/a_test_stream/0”,
“relation”: “alternate”
}
]
}
]
}%

``

Set max count

{
“$maxCount”: 1
}

``

curl -i -d @metadata.json http://localhost:2113/streams/a_test_stream/metadata -u admin:changeit -H “Content-Type:application/json” -H “ES-EventId: 1511fcc2-12d5-4939-ba14-d7a3255088d5”
HTTP/1.1 201 Created

``

Check stream again

curl -i http://localhost:2113/streams/a_test_stream -H “accept:application/json” -u admin:changeit
HTTP/1.1 200 OK
Access-Control-Allow-Methods: POST, DELETE, GET, OPTIONS
Access-Control-Allow-Headers: Content-Type, X-Requested-With, X-Forwarded-Host, X-PINGOTHER, Authorization, ES-LongPoll, ES-ExpectedVersion, ES-EventId, ES-EventType, ES-RequiresMaster, ES-HardDelete, ES-ResolveLinkTo, ES-ExpectedVersion
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: Location, ES-Position
Cache-Control: max-age=0, no-cache, must-revalidate
Vary: Accept
ETag: “1;1391431453”
Content-Type: application/json; charset=utf-8
Server: Mono-HTTPAPI/1.0
Content-Length: 1309
Keep-Alive: timeout=15,max=100

{

“entries”: [
{
“title”: “1@a_test_stream”,
“id”: “http://localhost:2113/streams/a_test_stream/1”,
“updated”: “2016-02-08T11:00:51.097326Z”,
“author”: {
“name”: “EventStore”
},
“summary”: “eventType”,
“links”: [
{
“uri”: “http://localhost:2113/streams/a_test_stream/1”,
“relation”: “edit”
},
{
“uri”: “http://localhost:2113/streams/a_test_stream/1”,
“relation”: “alternate”
}
]
}
]
}%

``

Do you mind pasting your curls with but also including -i in them? e.g.

curl **-**i http://localhost:2113/streams/a_test_stream -H “accept:application/json”-u admin:changeit

``

Thank you

~> curl -i “http://eventstore-1.local:2113/streams/my-stream” -H “Accept:application/json” --user admin:changeit

HTTP/1.1 200 OK

Access-Control-Allow-Methods: POST, DELETE, GET, OPTIONS

Access-Control-Allow-Headers: Content-Type, X-Requested-With, X-Forwarded-Host, X-PINGOTHER, Authorization, ES-LongPoll, ES-ExpectedVersion, ES-EventId, ES-EventType, ES-RequiresMaster, ES-HardDelete, ES-ResolveLinkTo, ES-ExpectedVersion

Access-Control-Allow-Origin: *

Access-Control-Expose-Headers: Location, ES-Position

Cache-Control: max-age=0, no-cache, must-revalidate

Vary: Accept

ETag: “37088;-43840953”

Content-Type: application/json; charset=utf-8

Server: Mono-HTTPAPI/1.0

Nevermind!

My bad. I was sending incorrect payload.

[

{

“eventId”: “7c314750-05e1-439f-b2eb-f5b0e019be72”,

“eventType”: “$metadata”,

“data”: {

“$maxCount”: 1

}

}

]

Now it works as expected

~> curl -i “http://eventstore-1.local:2113/streams/my-stream” -H “Accept:application/json” --user admin:changeit

HTTP/1.1 200 OK

Access-Control-Allow-Methods: POST, DELETE, GET, OPTIONS

Access-Control-Allow-Headers: Content-Type, X-Requested-With, X-Forwarded-Host, X-PINGOTHER, Authorization, ES-LongPoll, ES-ExpectedVersion, ES-EventId, ES-EventType, ES-RequiresMaster, ES-HardDelete, ES-ResolveLinkTo, ES-ExpectedVersion

Access-Control-Allow-Origin: *

Access-Control-Expose-Headers: Location, ES-Position

Cache-Control: max-age=0, no-cache, must-revalidate

Vary: Accept

ETag: “37155;-43840953”

Content-Type: application/json; charset=utf-8

Server: Mono-HTTPAPI/1.0

Content-Length: 1318

Keep-Alive: timeout=15,max=100

{

“title”: “Event stream ‘my-stream’”,

“id”: “http://eventstore-1.local:2113/streams/my-stream”,

“updated”: “2016-02-08T11:46:36.16208Z”,

“streamId”: “my-stream”,

“author”: {

“name”: “EventStore”

},

“headOfStream”: true,

“selfUrl”: “http://eventstore-1.local:2113/streams/my-stream”,

“eTag”: “37155;248368668”,

“links”: [

{

“uri”: “http://eventstore-1.local:2113/streams/my-stream”,

“relation”: “self”

},

{

“uri”: “http://eventstore-1.local:2113/streams/my-stream/head/backward/20”,

“relation”: “first”

},

{

“uri”: “http://eventstore-1.local:2113/streams/my-stream/37156/forward/20”,

“relation”: “previous”

},

{

“uri”: “http://eventstore-1.local:2113/streams/my-stream/metadata”,

“relation”: “metadata”

}

],

“entries”: [

{

“title”: “37155@my-stream”,

“id”: “http://eventstore-1.local:2113/streams/my-stream/37155”,

“updated”: “2016-02-08T11:46:36.16208Z”,

“author”: {

“name”: “EventStore”

},

“summary”: “tick”,

“links”: [

{

“uri”: “http://eventstore-1.local:2113/streams/my-stream/37155”,

“relation”: “edit”

},

{

“uri”: “http://eventstore-1.local:2113/streams/my-stream/37155”,

“relation”: “alternate”

}

]

}

]

}

``

That payload would work with a different content type.

You mean application/vnd.eventstore**.events+json**?

Yep! that media type takes the stuff posted and looks inside of it.
application/json just takes the content as the data

Cool, thanks!