wersonliu9527
V2EX  ›  Node.js

关于 nodejs 的 mysql orm 映射 Sequelize 库的问题

  •  
  •   wersonliu9527 · Dec 12, 2018 · 4317 views
    This topic created in 2719 days ago, the information mentioned may be changed or developed.
    let getjob = async (params) => {
    let jobs = await Lagou.findAll({
    where: {
    city: params.city ,
    education: params.education ,
    keyword: params.keyword ,
    }
    });
    for (let i of jobs) {
    console.log(JSON.stringify(i));
    }
    };
    let mobj = {
    city: '深圳', keyword: 'java', education:'本科'
    };
    getjob(mobj);

    假如用户有三个参数 city keyword education 可选,如何通过一个方法来实现,传 1-3 个参数得到相应的数据呢
    2 replies    2018-12-13 10:12:53 +08:00
    ginozhu
        1
    ginozhu  
       Dec 12, 2018   ❤️ 1
    蛤?直接 where: {...params}
    yimity
        2
    yimity  
       Dec 13, 2018 via Android
    其实这个主要是你写法的问题。
    另一个方法试试 or。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2895 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 13:48 · PVG 21:48 · LAX 06:48 · JFK 09:48
    ♥ Do have faith in what you're doing.