为什么我会收到“在编译 FIRST 时检测到未定义的绑定”?

问题描述

我有一个有 3 条路线的应用:注册登录和仪表板;仪表板是受保护的路线。

在我的仪表板路由中,我正在创建一个将检索用户信息的发布请求。

在我的服务文件中:

//Return a user by ID
const getUserById = (id) =>
  knex('users').select('user_name').where({ user_id: id }).first();

在我的控制器文件中:

async function create(req,res,next) {
  try {
    const user = await service.getUserById(req.user);
    res.json(user);
  } catch (err) {
    console.error(err.message);
  }
}

我收到此错误

Undefined binding(s) detected when compiling FirsT. Undefined column(s): [user_id] query: select "user_name" from "users" where "user_id" = ? limit ?

我的表 users 有 4 列:user_id、user_name、user_email 和 user_password。

我的服务文件或控制器文件有什么问题?

解决方法

从代码来看,using System; namespace RayTracerChallange { public class Toople { public float x,y,z,w; public Toople(float X,float Y,float Z,float W) { x = X; y = Y; z = Z; w = W; } public Toople Add(Toople Toop) { return new Toople(this.x + Toop.x,this.y + Toop.y,this.z + Toop.z,this.w + Toop.w); } public class Point : Toople { Point(float X,float Z) : base(X,Y,Z,1) { this.x = X; this.y = Y; this.z = Z; } } public class Vector : Toople { Vector(float X,0) { this.x = X; this.y = Y; this.z = Z; } } 必须是未定义的。