是否有与 petapoco 相当的 Scala 版本?
我正在学习 SCALA,但一直没能找到我喜欢的简单的 Scala“微 ORM”。我正在寻找一些非常轻量的东西,比如 petapoco (http://www.toptensoftware.com/petapoco/)。我能找到的最接近的东西是 anorm,但它似乎要求您指示它如何映射到数据库/从数据库映射。
在 petapoco 中,我可以这样做:
foreach (var a in db.Query<article>("SELECT * FROM articles"))
{
Console.WriteLine("{0} - {1}", a.article_id, a.title);
}
或者(如果我没有课程,但想直接传递给 Json,那就更好了):
return Json(db.Query<dynamic>("Select name, id From people"));
提前致谢!
I'm learning SCALA, and haven't been able to find a simple Scala "micro-ORM" that I like. I'm looking for something very light weight like petapoco (http://www.toptensoftware.com/petapoco/). The closest thing I could find is anorm, but it seems to require that you instruct it on how to map to/from the database.
In petapoco, I can do this:
foreach (var a in db.Query<article>("SELECT * FROM articles"))
{
Console.WriteLine("{0} - {1}", a.article_id, a.title);
}
Or (even better in cases where I don't have a class, but want to pass straight through to Json):
return Json(db.Query<dynamic>("Select name, id From people"));
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你可以看看OrmLite(一个java轻量级ORM)或Squeryl.不确定其中任何一个是否支持将查询结果直接转换为 Json。另一种选择是lift mapper。如果您选择使用 lifts json 功能,转换为 json 将相当简单。
You could take a look at OrmLite (a java lightweight ORM) or Squeryl. Not sure if either of those support transforming a query result to Json directly. Another alternative would be lift mapper. If you go with that transforming to json would be fairly straightforward using lifts json capabilities.