Postgres数据库索引

时间:2018-09-27 09:58:06

标签: postgresql unique

我想在某些条件下创建约束。由于无法将其设为Hibernate,因此我尝试在Postgres数据库中进行设置。

下面是我的索引

如果 instrument_project_id 非空,则名称,工具,instrument_project_id 的组合应为唯一。< / p>

const data = "your JSon"
@computed get countries(){
.map(item => {
return <option key ={item.country.id}> {item.country.name} </option>
}
}
let cities : [];

@computed get cities(){
if(this.cities == null || this.cities == undefined)
return null;

this.cities.map(item => {
return <option key ={item.id}> {item.name} </option>
}
}

countryChange(){
this.cities = data.filter(item => {return item.country === "your value"})[0].cities
}

<select onchange= {this.countryChange}> {this.countries} </select>
<select onchange= > {this.cities } </select>

如果 instrument_project_id为空,则名称,工具的组合应为 唯一

create unique index on public.calibration (name, instrument, instrument_project_id) 
where instrument_project_id is not null;

无法正常工作。

0 个答案:

没有答案