badvancouver.blogg.se

Todolist app using mongodb
Todolist app using mongodb




The server directory structure will be: go-todo - server - middleware - middleware.go - models - models.go - router - router.go - main.go Server in GolangĬreate a server directory inside the go-todo. Note: This project is developed outside the GOPATH due to which the local imports are working.Ĭreate a project directory and give it an appropriate name. If you don’t, I’ll explain all the steps and will mention the references of the related topics. This is next problem, i’m sure solution in mongodb using things like mongoid will be much more developer friendly then building things “rawly” in redis hiredis client.I am assuming that you have Go installed and have a basic understanding of it. I will supply some code to cover it more in part two. Implementing priority list in mongodb will be totally custom solution while in redis we can just use zset. The place where redis OWNS mongodb in this context is “strucutres” and we use a lot of them to store data like this, lists sets, zsets. You can adjust this designs to your situation by changing lists to sets etc. Solution in redis is really fast and if you will implement lazy loading it will be very fast. SummaryĪll of this solutions have some pros and cons, mongodb excels better when documents are bigger (limit is set on 16 mb per document) than loads of small documents (massive waste of space). In this example we will use built in “array” operators creatingĪnd this way we can use find tool very easy and get documents fast. Well this case upfront is easier to grasp because for each list we can use single document or collection of documents lets talk about both solutions. Each user in his own space will have short lists, there is no danger of “ultimate” non splittable lists. This is because i want to isolate each user space easy.

todolist app using mongodb

Important thing is that i scope everything to user key / id. Things like pagination, calculating time are all left to app layer. And same the other way, normal ui will pull task test, when it was created and tags to display so we want to have this data ready. If user will click on particular tag like “redis” you want to get it O(1) time not O(N) after searching all keys. Why we have both lists ? To make it fast while searching. This example shows what we need to do to tag a task with something and how to peek tasks tagged with it.






Todolist app using mongodb