{"id":21450914,"url":"https://github.com/soontao/cds-materialized-view","last_synced_at":"2025-10-10T04:04:03.531Z","repository":{"id":65238135,"uuid":"569688624","full_name":"Soontao/cds-materialized-view","owner":"Soontao","description":"CDS Materialized View","archived":false,"fork":false,"pushed_at":"2025-10-07T17:49:46.000Z","size":1589,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-10-07T19:41:43.617Z","etag":null,"topics":["cap","cds","materialized-view"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Soontao.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2022-11-23T11:52:07.000Z","updated_at":"2025-10-07T17:49:49.000Z","dependencies_parsed_at":"2024-01-13T04:24:55.164Z","dependency_job_id":"ca693351-6ba8-44e9-a153-302a283961cc","html_url":"https://github.com/Soontao/cds-materialized-view","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":"Soontao/ts-project-template","purl":"pkg:github/Soontao/cds-materialized-view","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Soontao%2Fcds-materialized-view","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Soontao%2Fcds-materialized-view/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Soontao%2Fcds-materialized-view/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Soontao%2Fcds-materialized-view/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Soontao","download_url":"https://codeload.github.com/Soontao/cds-materialized-view/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Soontao%2Fcds-materialized-view/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279002680,"owners_count":26083440,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-10T02:00:06.843Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cap","cds","materialized-view"],"created_at":"2024-11-23T04:16:59.383Z","updated_at":"2025-10-10T04:04:03.508Z","avatar_url":"https://github.com/Soontao.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CDS Materialized View\n\n\u003e Materialized View for CAP NodeJS Runtime\n\n[![npm](https://img.shields.io/npm/v/cds-materialized-view)](https://www.npmjs.com/package/cds-materialized-view)\n[![node-test](https://github.com/Soontao/cds-materialized-view/actions/workflows/nodejs.yml/badge.svg)](https://github.com/Soontao/cds-materialized-view/actions/workflows/nodejs.yml)\n[![codecov](https://codecov.io/gh/Soontao/cds-materialized-view/branch/main/graph/badge.svg?token=xzBkWloYNR)](https://codecov.io/gh/Soontao/cds-materialized-view)\n\n## Get Started\n\n### Prerequisites\n\n`cds-materialized-view` depends on the [`cds-mtxs`](https://cap.cloud.sap/docs/guides/multitenancy/mtxs) features/services, so MUST setup `cds-mtxs` firstly.\n\n### Setup\n\nenable plugin\n\n```json\n{\n  \"cds\": {\n    \"plugins\": [\"cds-materialized-view\"],\n    \"materialized\": {\n      \"view\": {\n        \"refresh\": {\n          \"interval\": 1800\n        }\n      }\n    }\n  }\n}\n```\n\nthen annotate some view with annotations\n\n```groovy\nnamespace test.resources.csv.app.db;\n\nentity Person {\n  key ID   : Integer;\n      Name : String(255);\n}\n\n@cds.materialized.view // create materialized view\n@cds.materialized.interval : 3600 // refresh interval: per hour\nview UniqPersonNames as select distinct Name from Person;\n```\n\nnow, it works!\n\n## Parameters\n\n- `cds.materialized.view.refresh.jobs` - default `true` - enable job to refresh views, typically maybe need to setup only one instance to run the jobs\n- `cds.materialized.view.refresh.interval` - default `3600 seconds` - default global refresh interval for materialized view, for each view developer could use `@cds.materialized.interval` annotation to overwrite this\n- `cds.materialized.view.refresh.concurrency` - default `10` - concurrency of materialized view refresh\n- `cds.materialized.check.view.interval` - default `1 second` - interval between collect views need to be refreshed, then refresh them\n- `cds.materialized.view.refresh.header` - default `false` - add `x-cds-materialized-view-refresh-at` header to response\n\n## Features\n\n- [x] support materialized view\n  - [x] create table for materialized view\n  - [x] rewrite query\n    - [ ] rewrite string query\n    - [ ] rewrite array query\n  - [x] filter\n  - [x] aggregation\n  - [ ] view join table\n  - [ ] virtual elements\n  - [ ] projection join\n- [ ] shortcut for `$count` query\n  - [ ] hottest query\n  - [ ] count all\n- [x] support `x-cds-materialized-view-refresh-at`\n- [ ] support reuse existed materialized view\n- [ ] support to `redirect` to existed materialized view\n- [ ] support new service(interface) to support refresh materialized view by API/Rest API\n\n## [LICENSE](./LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoontao%2Fcds-materialized-view","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsoontao%2Fcds-materialized-view","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoontao%2Fcds-materialized-view/lists"}