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

Allow setting a custom method/property as the primary key (_id) #61

Open
rubenrails opened this issue Aug 5, 2015 · 3 comments
Open
Milestone

Comments

@rubenrails
Copy link

Currently, there are a couple of ways of achieving this, either by overriding the id method entirely, or by using a callback (e.g. before_save).

It'd be better if we could do something like:
Option A)

class Product < Dolly::Document
  property :sku, primary: true
end

Option B)

class Product < Dolly::Document
  property :sku

  primary :sku
end
p = Product.new
p.sku = "sau101"
p.id # "product/sau101"

It should work with either document propertys or arbitrary instance methods.

@javierg
Copy link
Member

javierg commented Aug 5, 2015

I prefere option "A", also, maybe explicitly override the "namespace" of the document which will sometimes differ from the class one, specially if we are using inheretance,

@seancookr
Copy link

This is an interesting feature to add. I shall ponder these ideas further

@javierg javierg added this to the 1.0 RC milestone Aug 13, 2015
@seancookr
Copy link

I think this is also a feature and should not be included in 1.0 stable

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

No branches or pull requests

3 participants