wwwision / projection-playground
Neos backend module that allows for creating and testing ESCR projections on the fly
Fund package maintenance!
bwaidelich
Paypal
Installs: 0
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 5
Language:CSS
Type:neos-package
Requires
Requires (Dev)
- roave/security-advisories: dev-latest
- dev-main
- 0.2.0
- 0.1.0
- dev-dependabot/npm_and_yarn/Resources/Private/Svelte/semver-5.7.2
- dev-dependabot/npm_and_yarn/Resources/Private/Svelte/qs-and-express-6.11.0
- dev-dependabot/npm_and_yarn/Resources/Private/Svelte/json5-1.0.2
- dev-dependabot/npm_and_yarn/Resources/Private/Svelte/minimist-1.2.8
- dev-dependabot/npm_and_yarn/Resources/Private/Svelte/decode-uri-component-0.2.2
This package is auto-updated.
Last update: 2024-12-13 08:19:48 UTC
README
Neos backend module that allows for creating and testing ESCR projections on the fly
Usage
install via composer:
composer require wwwision/projection-playground
Note At the time of writing, the
neos/contentrepository-core
package is not yet available on packagist You can download it from GitHub to your distribution folder: https://github.com/neos/neos-development-collection/tree/9.0/Neos.ContentRepository.Core and install everything viacomposer require wwwision/projection-playground neos/contentrepository-core:@dev
Afterwards, if you log into the Neos Backend as an Administrator, you can navigate to the new backend module at /neos/administration/projection-playground
and start playing.
Projections
The projection logic can be written in JavaScript. This package supports a subset of the EventStoreDB projection syntax (see Documentation)
Example projections
Count all events
fromAll() .when({ $init: () => ({count: 0}), $any: (s, e) => { s.count ++; } })
Count created node types
...and transform the result to order them by most used type
fromAll() .when({ NodeAggregateWithNodeWasCreated: (s, e) => { const nodeType = e.body.nodeTypeName; s[nodeType] = (s[nodeType] ?? 0) + 1; } }).transformBy(s => Object.fromEntries(Object.entries(s).sort((a, b) => b[1] - a[1])))
Aggregate events by their weekday
...and transform the result to order them by most popular day
fromAll() .when({ $any: (s, e) => { const timestamp = e.metadataRaw['initiatingTimestamp']; if (!timestamp) { return; } const date = new Date(timestamp); const weekDay = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"][date.getDay()]; s[weekDay] = (s[weekDay] ?? 0) + 1; } }).transformBy(s => Object.fromEntries(Object.entries(s).sort((a, b) => b[1] - a[1])))
Disclaimer
This project is not endorsed by Event Store Ltd.