尝试以整数形式存储数组值。这是我的代码。这是错的吗? [英] Trying to store array values in integer . This is my code . Is it wrong?

查看:52
本文介绍了尝试以整数形式存储数组值。这是我的代码。这是错的吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将多个id存储到users表的student_id列。但它有部门表_id的引用,它是由int类型声明的,所以如果你有任何想法请建议我



我尝试了什么:



i would like to store multiple id's to the student_id column of users table. but it has the reference of departments table _id which is declared by int type so if you have any idea please suggest me

What I have tried:

db.query('INSERT INTO users(name,student_id) VALUES($1,ARRAY["$2","$3"]::INTEGER[]) RETURNING *', [data.name, data.id])
.then(function(user) { })
.catch(function(err) {
    return callback(null, err);
})

推荐答案

1,ARRAY [


2,


3] :: INTEGER [])RETURNING *',[data.name,data.id])
.then( function(user){})
.catch(function(err){
return callback(null,err);
})
3"]::INTEGER[]) RETURNING *', [data.name, data.id]) .then(function(user) { }) .catch(function(err) { return callback(null, err); })


这篇关于尝试以整数形式存储数组值。这是我的代码。这是错的吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆