CDS plugin for easy implementation of number range fields.
npm install cds-numberrange-pluginThis is a plugin for CAP framework to let you easily add database ranges into your applications.
You can use this plugin to add auto-incremented fields into your database. There are different options to format the auto-incrementation:
- Basic Configuration allows you configure integer fields starting from specific number and increment by configured number.
- It is also possible to format the generated number with prefix, suffix characters and also pad the generated number with a 0 or any other characters.
Installing plugin with npm install
```
npm install cds-numberrange-plugin
In your package.json file, add the following part into the CDS node:
`json`
"cds": {
"cds-numberrange-plugin": {
"ranges": [
{
"name": "
"start": 1,
"increment": 1,
"createOnDraft": true,
"additionalProperties": {
"prefix": "P",
"suffix": "S",
"padCount": 10,
"padValue": "0"
}
}
]
}
}
Then, you can annotate your fields in your database schema with special @plugin.numberrange.rangeid annotation.
```
annotate
}
This annotation make this field automatically filled with range format configured in your package.json file.
#### samples/sample-01-sqlite-in-memory
This samples demonstrates the plugin in sqlite-in-memory database with different configuration options.
#### samples/sample-02-sqlite-persistent
This samples demonstrates the plugin in sqlite persistent database with different configuration options.
This samples demonstrates the plugin in SAP HANA database with different configuration options.
This sample demonstrates the plugin with draft activated entities. You can configure your ranges to be created either in draft mode or after draft activation. Keep in mind that key fields must be configured in draft mode.
- Make sure you don't modify manually the field values that has been configured to use the plugin.