[Nitro] a 'database' entity?

Jonathan Buch john at oxyliquit.de
Wed Jun 7 08:37:17 EDT 2006


> A database entity would be the collection of the table items that one  
> (now) keeps in their model.rb file.  In technical database terms it is  
> everything in a "subschema".  (Or some DBMS also name this as "schema".   
> Pedantically a "schema" is everything managed by a DBMS, and more of a
> management item than anything of application interest.)
> A database entity is the structure for the tables and other structures  
> that are all related to the same thing.  A database encapsulates these
> model objects as the owner object.

This description fits $db = Og.start(....) very well..

> In this simple case, a high-level database entity would be something  
> like:
>     class BasicBlog
>        entity  :Category
>        entity  :Post
>        entity  :Comment
>     end

This is done by:

$db.manage_classes(Foo, Bar, Asdf)

right now, although I have to say that you idea of how to put the Models
into a Database is very nice. George, you see this as well?

> My notion of structure and encapsulation suggests to me that if a  
> framework manages internals automatically, then I should not need to
> know any of  the internals unless I'm curious or actually working on
> the framework.

Well, that is true, actually you shouldn't even be asking those questions
if you didn't want to know about internals ;D
That it is kind of icky right now to get 2 databases running, is a pity
yes, but if you'd just run a single database, you wouldn't ever had
to look into how your Data is managed (if you are meaning by 'internals'
how the data is managed)

> My present understanding is that I can't connect something called
> "BasicBlog" and say scan the 'database entity' such as:

You can:

>     myblog = BasicBlog.new( ... )
>     myblog.each do | item |
>     {
>         ... Clean up old entries ...
>     }

   require 'myblog_models.rb'
   myblog = Og.setup(..)
   myblog.managed_classes.each do |item|
     # clean up old entries

That is, if you mean by myblog.each that you want to iterate over your
previously defined Entities (entity :Category).
If you mean by that, that you want to iterate over all existing 'objects'
in your database, then you could use:

   items = myblog.managed_classes.map {|x| x.all }.flatten
   items.each do |item|
     # do stuff here

x.all is like Category.all, it will return all category objects.

Although I doubt the usability of something like that in the most cases..

> I can do something similar if I understand some internals for Og, the  
> major comment on that is conceptual.  The encapsulation is suitableor  
> not suitable for the purpose at hand.  I'm outlining the substanceof my  
> observation.

Atm the problem is just that the documentation is missing.
A quote:
>  <paca>   I don't know about the learning curve..  but the "running" 
>           curve is pretty steep..
>  <Kashia> well, that's kind of the same right now *g*

Similar applies here, actually you don't have to know Og internals, you
have to have basic information on how-stuff-works which is a bit lacking
unfortunately. (Yes, that is quite a understatement ;D)

Or maybe I'm misunderstanding your definition of 'internals'? For me,
Og internals are how *Og* does something (like how it fetches stuff from  
DB and makes Ruby objects from it), not how *I* can do what I want (for
example, how can I get all managed classes from an Og instance (DB object))

> As a novice player, the result of  Og.setup( ... )  'would' correspond  
> to my example BasicBlog.new( ... )

What is the second part of this sentence? ('would' correspond to... *if*  

Like I see it, Og.setup does exactly what BasicBlog.new would do (maybe not
as nice, code-wise)

I hope those directions put you on the right path and that you're able
to use nitro how you would like to.


Feel the love

More information about the Nitro-general mailing list