wwwision/projection-playground
最新稳定版本:0.2.0
Composer 安装命令:
composer require wwwision/projection-playground
包简介
Neos backend module that allows for creating and testing ESCR projections on the fly
README 文档
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-corepackage 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.
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-04-26