-
Notifications
You must be signed in to change notification settings - Fork 146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Different data models? #53
Comments
+1 I love the idea. I've been thinking about doing this myself. |
The goal of poet is to remain simple -- hence the parsing a directory for posts without needing a database. Although, if having a database makes it simple, then it's something to explore. Although, I'd like to keep the posts stored in memory, as if the posts were fetched from the DB on call, it would require a much different infrastructure than what's in place currently. To fetch posts initially from a database, and then at that point, everything else is the same as with directory posts, then that could be doable. 👍 on it being a separate module in the above scenario -- will look into what would need to be changed to allow this extensibility. Currently, the Is that what you had in mind? A DB way to populate posts, and from that point forward, business as usual? |
Yes, that's exactly what I had in mind: abstracting the data model to a separate module that fills the in-memory cache with posts, and then carry on as usual. We could have a The first proof of concept would be to abstract away the current, default data model into its own module (which may as well be kept included in the repo). Also, the existing |
What if we used something like https://github.com/balderdashy/waterline which already has a "dirty" RAM backing along with many other drivers. |
waterline could be a great module to use for this.. will look into that, and into decoupling poet so the 'load posts' is separated from everything else |
I would really like to help with this. Any thoughts as to how we might want to decouple the "Load posts" implementation? |
I have a start on an implementation with mongodb at https://github.com/mfrobben/poet-mongo. It's rough and hacked in, but you get the idea. Also have a working admin panel hacked onto that at https://github.com/mfrobben/poet-mongo-admin. Agree with @jackmaney there should be better abstractions than (options.useDb ? foo() : bar()), but you get the point. :) |
I like your implementation @mfrobben very clean and well documented! this would definitely make a good starting point! 👍 |
First of all, let me say that I love what has been done with Poet. Before I bumped into it, I did some brainstorming on what I'd want from a relatively simple blog engine that I could attach to my homepage (the back-end of which is run in node), and Poet is almost a superset of the features I want. I'm in the process of tinkering with Poet and adding it to my website.
While using the local file system for posts is nice for its simplicity, it can be a bit of a pain for apps using Poet that are a) kept on GitHub, and b) deployed elsewhere (eg Heroku), since the deployment cycle is essentially
create blog post -> commit to GitHub -> deploy to Heroku (or wherever)
and that's a rather annoying process. If posts can instead be added to a database/No SQL key-value store/etc, then no such deployment is necessary.
I propose adding different data models to Poet, allowing the storage of posts in databases, as follows:
poet-model-mongo
,poet-model-mysql
, etc) should be their own node modules.options
which would default to the current choice of using the app's local file system.options
, there is an optional object with a key ofmodelOptions
that includes, eg, access credentials, the host name of the database to connect to, etc.getPost
,getPosts
,getPostsWithTag
, etc. This would mean thatcreateHelpers
would just call the relevant data helper methods from the given data model.Would this kind of thing be welcome?
The text was updated successfully, but these errors were encountered: