Based on what I understand about Discriminators, this:
// removed strict:false and added discriminatorKey for meta.start, meta.end, meta.date fields for type=event/call/note/reminder
...is bogus.
Tell me if I'm right...
A Discriminator is what connects two models together. For example, I have a base model where I define several fields as well as a "discriminator key." That "key" is actually another column that will be defined in a different model.
If I have a collection of books, a collection of movies and a collection of tv shows, they all have "titles" and "release dates." They're unique, however, in that each book has an "author," a TV Show has a "season" and a movie has "director."
I can set up my database in a way where I've got a "base" model that has two columns set aside for "titles" and "release date" and also includes a "discriminator key" called, "itemtype." You can almost think of this as an abstract class in that you'll never directly called the "base" model, although it's present in every one of the other models that you will call.
My "books" model will have a single column called "author." But in reality, the "books" model will be processed as having, not just the "author" column, because it's an extension of the "base" model, it will include all of the other columns referenced in the "base" model as well.
So, for all intents and purposes, when we go to retrieve the info from the "book" collection (which is based on the "book.js" model), it will look like this:
What you see in bold is the "discriminator key" established in the "base" model.
Notice in the base.js file, the "discriminator key" is referred to as "itemtype." That's just a place holder. When it's actually rendered, that column will read "author" for books, "director" for movies and "season" for TV shows.
is that explanation correct?
Based on that explanation, when I do a search for "discriminator" in my schemas directory, it shows up one time and one time only and that's in the "Activity.js" schema that you see above.
That seems wrong for two reasons.
First of all, I don't see how the Activity.js schema is serving as a "base" for another model and...
...a Discriminator key is not going be named according to an incoming piece of data. Based on what I understand that key is a unique placeholder and to refer to it using the same name as an incoming value is wrong.
When I remove this: { discriminatorKey: 'type' }
I can add as many notes as I want to and will not get that error.
But have I compromised something else based on the "// removed strict:false and added discriminatorKey for meta.start, meta.end, meta.date fields for type=event/call/note/reminder" comment?
”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.
-Mike Kapnisakis, Warner Bros
With your subscription - you'll gain access to our exclusive IT community of thousands of IT pros. You'll also be able to connect with highly specified Experts to get personalized solutions to your troubleshooting & research questions. It’s like crowd-sourced consulting.
We can't always guarantee that the perfect solution to your specific problem will be waiting for you. If you ask your own question - our Certified Experts will team up with you to help you get the answers you need.
Our certified Experts are CTOs, CISOs, and Technical Architects who answer questions, write articles, and produce videos on Experts Exchange. 99% of them have full time tech jobs - they volunteer their time to help other people in the technology industry learn and succeed.
We can't guarantee quick solutions - Experts Exchange isn't a help desk. We're a community of IT professionals committed to sharing knowledge. Our experts volunteer their time to help other people in the technology industry learn and succeed.
Our community of experts have been thoroughly vetted for their expertise and industry experience.