ActiveRecord + NDB = Og

Hello everyone,

after releasing the NDB Object-Relations mapping library some time
ago a lot of people suggested that I should include multiple
backend support (especially MySQL) and some features of ActiveRecord.
Moreover, I saw on the Rails wiki that some people would like
to add some NDB features to ActiveRecord (ie the ActiveSchema
proposal).

Og (ObjectGraph) is a new project that enhances NDB with
an ActiveRecord-like domain language. You can find a preview release
with docs and an example in the latest Nitro distribution:

http://nitro.rubyforge.com

A stand-alone version will follow when the API is stabilized.

Btw I would like to make Og compatible with Rails too, so if a
Rails hacker wants to help he can contact me.
have fun,
George Moschovitis.

Here is a small example btw:

class Comment; end

class Article
has_many Comment, :comments
prop_accessor String, :title
prop_accessor String, :body
prop_accessor Hash, :options

def initialize(title = nil, body = nil)
@title = title
@body = body
@options = {"hello" => "world"}
end
end

class Comment
belongs_to Article, :article
prop_accessor String, :body
prop_accessor Time, :create_time

def initialize(body = nil)
@create_time = Time.now
@body = body
end
end

$og.manage_classes(Article, Comment)

article = Article.new("title", "the body")
article.save!

# lookup
article = Article[1]
article = $og.load(1, Article)

comment = Comment.new("the comment")
comment.article = article
comment.save!
# or
# $og << comment
# or
# Comment.save(comment)

p article.comments

The backend database and the schema for those objects
is created automatically.

have fun,
George Moschovitis

Hello everyone,

after releasing the NDB Object-Relations mapping library some time
ago a lot of people suggested that I should include multiple
backend support (especially MySQL) and some features of ActiveRecord.
Moreover, I saw on the Rails wiki that some people would like
to add some NDB features to ActiveRecord (ie the ActiveSchema
proposal).

I stripped Active Record's database adapter code out and made it into its own
lib. I talked to David H. and he thinks it's a great idea, in fact he dubbed
it 'Abstract Adapter', but I guess he doesn't have the time to pursue it. It
works well. I use it for my own ORM (much like yours in functionality I
think). Of course there is DBI, but Abstract Adapter is more ORM oriented.
Would you like to take this over? It worth it IMHO and Active Record and NDB
could share the same code base on this which should be a win-win.

Og (ObjectGraph) is a new project that enhances NDB with
an ActiveRecord-like domain language. You can find a preview release
with docs and an example in the latest Nitro distribution:

http://nitro.rubyforge.com

A stand-alone version will follow when the API is stabilized.

Cool.

Btw I would like to make Og compatible with Rails too, so if a
Rails hacker wants to help he can contact me.

Having direct ORM is the main thing Rails lacks that tuns me off about it. So
I would like to see this, but I think it may prove tricky.

Good stuff!
T.

ยทยทยท

On Monday 01 November 2004 08:38 am, George Moschovitis wrote:

Hello,

Of course there is DBI, but Abstract Adapter is more ORM oriented.
Would you like to take this over? It worth it IMHO and Active Record

and NDB

could share the same code base on this which should be a win-win.

I thought about reusing the abstract adapter from ActiveRecord but I
wasnt
sure David would find this a good idea :slight_smile: Anyway it really is no big
deal to write database adapters. If other people think that something
like you propose is interesting I could actually do it.

Rails lacks that tuns me off about it...

while you are at it, why dont you have a look at Nitro too, there are
lotsa changes coming really soon, but I would appreciate your opinion
and suggestions.

best regards,
George Moschovitis