Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8992053
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T22:52:01+00:00 2026-06-15T22:52:01+00:00

I have a Workspace and Document entities, with the idea that a workspace can

  • 0

I have a Workspace and Document entities, with the idea that a workspace can contain zero, one, or more documents. My first approach to model this was:

case class Workspace(name: String, documents: Seq[Document])

but this will not scale well since my workspaces may contain many documents. Fortunately, my business requirement allow me to treat workspaces and documents separately (in the sense that when I have a workspace, there is no reason or invariant that forces me to consider all documents contained in it).

Question: I am wondering: how would I model Workspace and Document in Sorm so that I have a link between the two but do not have to load all documents of a workspace? I imagine to have a Repository that would give me access to the documents of a workspace, with pagination support.)

case class Workspace(name: String)
case class Document(name: String, /* ... */)

trait WorkspaceRepository {
  def children(ws: Workspace, offset: Long, limit: Long)
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T22:52:02+00:00Added an answer on June 15, 2026 at 10:52 pm

    Easy peasy! You define them unrelated:

    case class Workspace ( name : String )
    case class Document ( ... )
    

    Then you choose a way you wish them to be linked. I see two.

    Variant #1

    case class WorkspaceDocuments 
      ( workspace : Workspace, documents : Seq[Document] )
    

    And get all documents of a workspace like so:

    Db.query[WorkspaceDocuments]
      .whereEqual("workspace", theWorkspace)
      .fetchOne()
      .map(_.documents)
      .getOrElse(Seq())
    

    In this case it makes sense to specify the workspace property as unique in instance declaration:

    ... Instance (
      entities = Set() +
                 Entity[WorkspaceDocuments]( unique = Set() + Seq("workspace") )
      ...
    )
    

    Variant #2

    case class WorkspaceToDocument
      ( workspace : Workspace, document : Document )
    

    And get documents of a workspace like so:

    Db.query[WorkspaceToDocument]
      .whereEqual("workspace", theWorkspace)
      .whereEqual("document.name", "...") // ability to filter docs
      .fetch()
      .map(_.document)
    

    First variant won’t let you filter docs in your query (at least in SORM v0.3.*) but due to ability to set a unique constraint on a workspace it should perform better on workspace-based queries. The second variant is more flexible, allowing you to apply all kinds of filters.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have several projects open in an Eclipse workspace. Like so: com.harbl.project.one com.harbl.project.two com.harbl.project.three
I have 2 uni-dimentional arrays in workspace, one (xarray) is to be used as
I have a Rails 3 model D that belongs to another model, which belongs
I have this script: window.onload = function(){ document.getElementById('workspace').oncontextmenu = function(){ return false; } }
I have cf installed in ~/Sites and my Eclipse projects are stored into ~/Documents/workspace
I have an application that currently uses Apache Abdera to parse Atom Pub documents
I have one workspace A with files checked out on computer A. Now I
I have a workspace with a bunch of java projects. If I go to
In my Shell window I have a workspace region to allow view switching via
By default configuration in a new workspace I have Run as Web Application in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.