我想了解选择使用用例、优点和不便是什么tools.org/mvnsites/liftweb-2.3/net/liftweb/record/Record.html">记录 , Mapper 或两者,在 Liftweb 应用程序。
当我尝试以下操作时出现了这个问题:
- 为模型类创建一个树状结构
- 创建一个类似的树状结构来渲染页面中的类
- 确保树中的不同类可以同时处于不同的状态。例如,一个处于编辑或创建状态,另一个处于可视化状态。
- 可以创建、读取模型类或将其保存到已运行的 RESTful Web 服务中。
我将用例放在这里只是为了记录。你可以用更笼统的方式来回答。
I would like to understand what are the use cases, advantages and inconveniences of choosing to use Record , Mapper or even both, in a Liftweb application.
This question came up when I tried to:
- create a tree like structure for the model classes
- create a similar tree like structure for rendering of the classes in a page
- ensure different classes in the tree can be in different states at the same time. One is in the EDIT or CREATE state and the other in the VISUALIZE state for example.
- model classes can be created, read or saved to a RESTful Web Service that is already functioning.
I'm putting the use cases here just for the record. You can answer in a more general way.
发布评论
评论(2)
在 Lift 成为 Lift 之前,Mapper 就已成为 Lift 的一部分。它是数据库和 Scala 之间的简单“Active Record”风格的桥梁。我根据这里概述的想法构建了 Mapper:
<一href="http://web.archive.org/web/20070303054927/http://blog.lostlake.org/index.php?/archives/19-Keeping-the-meaning-with-the-bytes.html ">http://web.archive.org/web/20070303054927/http://blog.lostlake.org/index.php?/archives/19-Keeping-the-meaning-with-the-bytes.html
Mapper 与 JDBC 以及关系数据库密切相关。 Mapper 有一种合理的机制来构建简单的查询,但对于复杂的东西,我们必须手动编写 SQL。
Mapper 很坚固但很粗糙。
Record 是后备存储和 Scala 之间更通用的抽象。它对“用字节保持含义”中概述的想法的实现较弱......并且很少有人注意到或关心。
MongoDB、CouchDB、Squeryl 和其他存储机制都有 Record 实现。编写一个新的后端需要几天的工作。
Record 有很多“异常”,每个后端都有自己的怪癖。当前的 Record 所有者已开始对 Record 进行大规模重构。
我不认为 Record 或 Mapper 会给你“开箱即用”的树状结构,除非你使用 MongoDB 后端,在这种情况下,你的树结构将基于 JSON 文档而不是关系。
Mapper has been part of Lift before Lift was Lift. It's a simple "Active Record" style bridge between the database and Scala. I built Mapper based on ideas outlined here:
http://web.archive.org/web/20070303054927/http://blog.lostlake.org/index.php?/archives/19-Keeping-the-meaning-with-the-bytes.html
Mapper is intimately tied to JDBC and thus relational databases. Mapper has a reasonable mechanism for building simple queries, but for complex stuff one has to hand-write SQL.
Mapper is solid but crufty.
Record is a more generic abstraction between backing store and Scala. It has weaker implementations of the ideas outlined in "Keeping the meaning with the Bytes"... and very few people notice or care.
There are Record implementations for MongoDB, CouchDB, Squeryl and other storage mechanisms. Writing a new back-end is a few days of work.
Record has a lot of "anomalies" and each back end has its own quirks. The current Record owner has embarked on a wholesale refactoring of Record.
I do not think either Record or Mapper will give you tree-like structures "out of the box" unless you're using the MongoDB backend and in that case, your tree structures will be based on JSON documents rather than relations.
嗯,Mapper 和 Record 库只是 Lift 应用程序中数据库访问的不同抽象。 Record 是较新的,被认为有一天会取代 Mapper。目前 Record 支持 CouchDB 和 MongoDB 等 NoSQL 数据库。如果您的数据模型适合 NoSQL 世界,请尝试 Record。否则,您可以将 Mapper 与典型的关系数据库结合使用。
我希望为您提到一些有趣的观点。
Well, the Mapper and Record libraries are only different abstractions for the database access in Lift applications. Record is the newer one and is considered to substitute Mapper one day. At the moment Record supports NoSQL databases like CouchDB and MongoDB. If your data model fits into the NoSQL world, try Record. Otherwise you can use Mapper in connection with a typical relational database.
I hopefully mentioned some interesting points for you.