haawebcam.blogg.se

Todolist app using mongodb
Todolist app using mongodb











  • model B would be tailored for an access pattern where you always list a complete folder and tasks are only edited when the folder is opened (if you retrieve one folder you have all the task without an additional query).
  • your model A is a way how you could do it in a relational database (each type of information in one table referenced over id).
  • The difference beeing that in a relational database you usually try to go for third normal form where one of the goals is to avoid bias to any form of access pattern where in mongodb you can try to model your data to best fit your access patterns (while keeping in mind not to introduce possible data anomalies through redundancy).

    todolist app using mongodb

    In there is a discussion of transitioning from a relational database model to mongo. Stumbled over this link which might be of interest for you.

    todolist app using mongodb

    If you need metadata for folders it can become a little more complicated but basically you could manage those independent of the tasks and users above using a folder collection containing the metadata with _id beeing the folder name referenced in user and task.Įdit: Comparison of the different approaches So without metadata for folders that is what I would do. Renaming a folder can be achieved with one update query on each of the collections.Ĭreating a folder or moving a task to another folder can also be achieved in simple manners. You can find all tasks within a folder with a simple find query for the folder name. With read_access beeing the respective array you got from your users document. You can get all tasks a user can read withĭb.task.find( ) The folder a specific user can access are automatically retrieved when you retrieve the user document so those can basically known at login.

  • User has arrays read_access and write_access.
  • If you don't need any metadata for the folder except the name you could also go with:
  • Requesting a folder means searching in a long list instead of having direct references (A) or just returning the folder (B).
  • Both need to be transmitted as well but there is no redundancy compared to A.
  • No way to update a Task without knowing the Folder.
  • Either those reference is stored within the Task (redundancy) or it must be passed with each API-call.
  • When updating a Task a reference to Folder is needed.
  • Maybe I missed some points or just have the wrong way of thinking. Usually (especially for syncing) tasks will be requested by-folder and not alone.īasically I thought about three approaches and would like to hear your opinion for them. Users may have different access to those folders (read, write) and tasks may be moved to other folders. The basic idea is a task-list where tasks are grouped in folders.

    todolist app using mongodb

    I want to learn mongo and decided to create a more complex todo-application for learning purpose.













    Todolist app using mongodb