gpt4 book ai didi

sql-server - 有没有支持用nodejs写linq to sql查询的JS库?

转载 作者:搜寻专家 更新时间:2023-10-31 22:32:32 25 4
gpt4 key购买 nike

我看到了 jslinq,看到了一起使用 node 和 SQL 的 tds js 库……那么有人曾经一起使用过这些技术吗?

我希望能够在 nodejs 应用程序中编写 linq to sql 查询...

最佳答案

本周我开始使用 LINQ to Entities 的 JS 变体。检查UniMapperJS

例子

var comments = await Comment.getAll()
.where(e => e.author.endsWith("something") || e.author.startsWith("somethingElse"))
.orderByDescending("created")
.limit(10)
.skip(0)
.exec();

但是由于 JS 的限制,很难弄清楚如何在 where 中接受变量,因为箭头函数被解析为字符串。我已经通过“虚拟”变量($)和 args 列表作为最后一个参数解决了这个问题。

var comments = await Comment.getAll()
.where(e => e.author.endsWith($) || e.author.startsWith($), filter.endsWith, filter.name)
.orderByDescending("created")
.limit(10)
.skip(0)
.select(e => e.author)
.exec();

关于sql-server - 有没有支持用nodejs写linq to sql查询的JS库?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9101932/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com