Skip to content

Instantly share code, notes, and snippets.

@ambantis
Last active December 24, 2015 10:28
Show Gist options
  • Save ambantis/6783988 to your computer and use it in GitHub Desktop.
Save ambantis/6783988 to your computer and use it in GitHub Desktop.
A Scala object that manages the tree of Google Drive files in MagicNotebook.io
case class MagicNotebook(tree: GFolder,
implicit val folders: Map[String, GFolder],
implicit val docs: Map[String, GDoc])
object MagicNotebook {
def create(userId: String)(implicit s: Session) = {
DbHomes.findById(userId).flatMap { fileId =>
DbGFolders.findById(fileId).map { tree =>
val folders = DbGFolders.findAllFor(fileId)
val docs = DbGDocs.findAllFor(fileId)
MagicNotebook(tree, folders, docs)
}
}
}
val empty = MagicNotebook(GFolder.empty, Map(), Map())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment