mongo_mysql_relations 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +39 -1
- data/lib/mongo_mysql_relations/version.rb +1 -1
- metadata +1 -1
data/README.md
CHANGED
@@ -18,7 +18,45 @@ Or install it yourself as:
|
|
18
18
|
|
19
19
|
## Usage
|
20
20
|
|
21
|
-
|
21
|
+
Add MongoMySqlRelations to your models (both Active record and mongoid)
|
22
|
+
|
23
|
+
class User < ActiveRecord::Base
|
24
|
+
include MongoMysqlRelations
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
and mongoid:
|
29
|
+
|
30
|
+
class Picture
|
31
|
+
include Mongoid::Document
|
32
|
+
include MongoMysqlRelations
|
33
|
+
end
|
34
|
+
|
35
|
+
on the mongo side you can use:
|
36
|
+
* to_mysql_belongs_to
|
37
|
+
* to_mysql_has_many
|
38
|
+
* to_mysql_has_one
|
39
|
+
|
40
|
+
and on the ActiveRecord side
|
41
|
+
|
42
|
+
* from_mysql_belongs_to
|
43
|
+
* from_mysql_has_many
|
44
|
+
* from_mysql_has_one
|
45
|
+
|
46
|
+
you'll need to specify the association class and sometimes the foreign key (in `has_*` associations)
|
47
|
+
|
48
|
+
class Picture
|
49
|
+
include Mongoid::Document
|
50
|
+
include MongoMysqlRelations
|
51
|
+
|
52
|
+
to_mysql_belongs_to :user, :class => User
|
53
|
+
end
|
54
|
+
|
55
|
+
class User < ActiveRecord::Base
|
56
|
+
include MongoMysqlRelations
|
57
|
+
|
58
|
+
from_mysql_has_many :pictures, :class => Picture, :foreign_key => "user_id"
|
59
|
+
end
|
22
60
|
|
23
61
|
## Contributing
|
24
62
|
|