M
M
mortify2016-05-01 19:21:15
ruby
mortify, 2016-05-01 19:21:15

How to implement such nosql, mongodb, mongoid structure?

Hello. Sketched such a database schema

{ 
 {
   "className": String,
   "classMethods": [{
       "methodName": String,
       "description": String,
       "exampleCode": String,
       "sourceCode" : String
     },
     {
       "methodName": String,
       "description": String,
       "exampleCode": String,
       "sourceCode" : String
     }]
 },
 {
   "anotherClassName": String,
   "anotherClassMethods": [{
         "methodName": String,
         "description": String,
         "exampleCode": String,
         "sourceCode" : String
       },
       {
         "methodName": String,
         "description": String,
         "exampleCode": String,
         "sourceCode" : String
       }]
 }
}

but I don’t understand at all how to implement it on mongoid, so that it also looks beautiful from the point of view of oop.
I had an idea to do something like this
class MyClass
    include Mongoid::Document
    field :name, type: String
    field :methods, type: Array
  end

but I don't think that's how it should work. Yes, and access to data in the array will then be problematic.
Please help me how to get out of this situation?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question