Saving Projections when using InMemDB

So I have some projections that I’d like to stay persistent between runs using --InMemDB during development. Rebuilding the projections’ results is fine but having to recreate or copy/paste the projection code is getting tedious. Am I missing something basic in the config to allow for this?

Thanks!

No you aren’t missing anything - projection definitions are simply events in the database so are also subject to in-memory storage.

Your best bet is to use a wrapper script which recreates the projections on startup.

James

Is there any documentation on this. Have been using Node.js for this project (built on top of ges-client) and there is no support for projections built in. I was doing a straight http requests for the projection results, are there related HTTP verbs to do CRUD related operations on projections?

There is no documentation on this yet.
The API is described in this controller. https://github.com/EventStore/EventStore/blob/release-v3.4.0/src/EventStore.Projections.Core/Services/Http/ProjectionsController.cs#L54-L94

For example, if you want to create a continuous projection here is the http request to do so.


curl -i -d @projection.json -H "content-type:application/json" "http://localhost:2113/projections/continuous?name=sample_projection&emit=no&checkpoints=yes&enabled=yes" -u admin:changeit

and the projection.json will contain the body of the projection you want to create

fromStream('$stats-127.0.0.1:2113')

.when({

$init:function(){

return {

count:0

}

},

$any:function(s,e){

s.count += 1;

return s;

}

});

Sweet! Thanks for this, should be enough to get me started!

Just an update if anyone stumbles upon this later.

request
    .post(`[http://localhost:2113/projections/continuous`](http://localhost:2113/projections/continuous%60))
    .query({
        name: path.basename(file,`.js`),
        emit: `no`,
        checkpoints: `yes`,
        enabled: `yes`
    })
    .auth('admin', 'changeit')
    .set('Accept', 'application/json')
    .send(data)
    .end(function (error, response) {
        if(error) {
            console.error(error);
        }
        else{
            const {body} = response;
            const {name} = body;
            console.log(name);
        }
    });

Using superagent here is what a working request looks like in node. Note the data is the javascript file (not json) being uploaded. Thanks Pieter for the help getting started!