0
我想在Loopback中自动生成模型的ID,以便第一个ID是1001,然后是1002,1003 ...等等。重要的是,所有ID都超过1000.在Loopback中自动生成以1000开头的ID
我已经尝试在保存和保存操作挂钩之前添加一个千位id值,但在挂钩之前id属性没有定义,并在挂钩后的变化是没有保存。我正在使用postgresql。
我该怎么做?在externalorder.json
我的模型的定义是:
{
"name": "Externalorder",
"base": "PersistedModel",
"idInjection": false,
"options": {
"validateUpsert": true
},
"postgresql": {
"schema": "public",
"table": "externalorder"
},
"properties": {
"externalorderId": {
"type": "number",
"id": true,
"generated": true,
"required": false,
"length": null,
"precision": 32,
"scale": 0,
"postgresql": {
"columnName": "externalorder_id",
"dataType": "integer",
"dataLength": null,
"dataPrecision": 32,
"dataScale": 0,
"nullable": "NO"
},
"_selectable": false,
"comments": "tilausnumero"
},
...
谢谢你的回答,虽然它不能真正解决我的问题,因为我特别需要以1000开头的id号。 – ritvje