Jobs (like a market place) and job (the role itself)

What I’m trying to conceive of is how should I approach this problem of having a marketplace e.g. where jobs are and can be searched for and then each job.

I feel like I would want a model for jobs and that model would be made up an array of references to every job within it’s collection. How while I feel that’s the structure when I say it out loud it seems to not make sense. A single monolithic collection with all the references to each ‘job’ collection seems incorrect.

Just a little detail, just to help give some visuals for those who wish it.
// using a mongoose-esqe seudo code here

 job.schema = {
     title: "web developer",
     description: 'lots of words here",
     company: "",
     contact: ["contact details"],
     other-stuff: ....
  }

// ‘Jobs/marketplace’ of roles.

 jobs.schema = {
    jobs: [{
          type: mongoose.Schema.Types.ObjectId,
          ref: "job"
      }, 
      {
          type: mongoose.Schema.Types.ObjectId,
          ref: "job"
    }]
 }

Now this seems a little crazy to me, but I’m not really sure how to change it for the better. I’d really appreciate it. I’m doing this for a small side hustle project just to learn more about Mongo, so please don’t feel that any feedback needs to represent a high end finished project just a nice push towards something more practical that I can iterate on over time. I just don’t want to totally break it with something so terribly conceived that I’d have to completely rethink it as my knowledge on the topic matures.

Your kind assistance is greatly appreciated. Thank you!!

Hi @misterhtmlcss ,

Welcome to MongoDB community!

I really recommend to any person that starts to design with MongoDB to go over the next two articles:
https://developer.mongodb.com/article/schema-design-anti-pattern-summary

Now regarding your specific schema questions, I think the following section is very related, which is how do I embedded relationships correctly to not overload the document and heavy lifting queries.

I would say that it might make more sense to reference each job to its market place. This way you can index an array of the marketplaces the jobs belong to. It can be just an id or maybe if names are unique a market name (it can be an array of small objects as well):

job.schema = {
     title: "web developer",
     description: 'lots of words here",
     company: "",
     contact: ["contact details"],
    marketPlace : [ "market1","market2"]
     other-stuff: ....
  }

This way when you would like to fetch all jobs for a specific market you will query an indexed jobs collection for the relevant jobs.

Of course you can still have a collection for market description and details related to the market or which are the current active markets.

Let me know if that makes sense.

Best
Pavel

1 Like

Hi Pavel,

Sorry for the slow reply, I don’t work full-time on this side hustle and also I wanted to take some time to actually review your material, the links and think too.

Firstly thank you. It is really helpful and actually gave me some ideas about other things I was thinking about too for my work. Awesome. I’m grateful.

Also I really do struggle with how to solve different problems without dipping into potential anti-patterns of which the blog article you linked to is really helpful.

This I believe solves my issues. I’ll bounce back if I have something more to ask around this issue such as a specific problem that sprouts from this information.

Cheers
Roger

2 Likes

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.