Skip to content
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

Database sytnax #3

Closed
sporkd opened this issue Jun 4, 2009 · 2 comments
Closed

Database sytnax #3

sporkd opened this issue Jun 4, 2009 · 2 comments

Comments

@sporkd
Copy link
Contributor

sporkd commented Jun 4, 2009

I'm not too crazy about the syntax of dealing with the database. To me it seems a bit cumbersome to need to manually get an instance of a database everytime you want to do something with a model.

I understand the advantages, it just seems like a case of letting testing considerations define the api. Possibly, I'm not to convinced either that models exist long enough in a typical stateless web app to really be weighed down. If you compare your couchrest sample wiki to the the couchpotato one, it seems like a lot of extra code to do the same thing.

So one idea... since the model is already decoupled from the database, would it make sense to have the save method on the model be responsible for getting an instance of the database right before save, and have it do something like db.save(self). Then loose the reference to the database when it's done.

That way, testing remains decoupled, but we don't have so much of the PHP reminiscent syntax. I know I am probably being picky here, but the model.save idiom in the ruby world is so beloved, I think it may be hard to deviate so much. I may be wrong however.

@langalex
Copy link
Owner

I'm not too crazy about the syntax of dealing with the database. To me it seems a bit cumbersome to need to manually get an instance of a database everytime you want to do something with a model.

the default instance is saved in CouchPotato.database and you are encouraged to put your instances into variables as well. for rails apps for example i usualy create a database method in my application controller that return a database instance so in my actions all i have to do is database.view or whatever.

how would a model's save method get access to a database instance?

@langalex
Copy link
Owner

langalex commented Oct 5, 2009

no action for 3 months so closed

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants