Compoundjs 我们如何在我们的shema中添加约束”;compoudjs/junglingdb“;

Compoundjs 我们如何在我们的shema中添加约束”;compoudjs/junglingdb“;,compoundjs,Compoundjs,我是一个初学者,我开始使用compoudjs,我使用JunglingDB作为数据库和jungglung postgres模块。 我的问题是,如何向创建的表添加约束? 我试试这个 var User=description('User',function(){ 属性('firstname',字符串); 属性('lastname',字符串); 属性('password',字符串,{limit:50); 属性('email',字符串{unique:true}); 属性(“已批准”,布尔值); 设置('r

我是一个初学者,我开始使用compoudjs,我使用JunglingDB作为数据库和jungglung postgres模块。 我的问题是,如何向创建的表添加约束? 我试试这个 var User=description('User',function(){ 属性('firstname',字符串); 属性('lastname',字符串); 属性('password',字符串,{limit:50); 属性('email',字符串{unique:true}); 属性(“已批准”,布尔值); 设置('restPath',pathTo.users); }); 但它不起作用

请帮忙。
坦克

我找到了一个解决方案:

在文件节点_modules/jugglingdb postgres/lib/prosgres.js中 通过添加约束,将“数据类型(p)”函数更改为:

    function datatype(p) {
 var q='';
if(p.unique!= undefined && p.unique)
{     q=' unique ';
 console.log(typeof(p.unique));
//
}
if(p.primaryKey!=undefined &&p.primaryKey)
{
    q=' primary key ';
}
if(p.notNull!=undefined &&p.notNull)
{
    q=' not null ';
}
if(p.check!=undefined )
{   //il faut definire manualement la condition de verification 
    q=' check('+p.check+') ';
    console.log(typeof(p.check));
}
if(p.constraintline!= undefined)
    q= ' '+p.constraintline;
if(p.constraint!= undefined)
    q= ' ,constraint '+p.constraint;
switch (p.type.name) {
    default:
    case 'String':
    case 'JSON':
    return 'varchar'+q;
    case 'Text':
    return 'text' +q;
    case 'Number':
    return 'integer' + q;
    case 'Date':
    return 'timestamp' + q;
    case 'Boolean':
    return 'boolean' + q;
}};