Menu

Unique combination of fields, no duplicates

2018-08-02
2018-08-21
  • Jeffrey Bostoen

    Jeffrey Bostoen - 2018-08-02

    I'm playing with the idea of a class where I'd need to have a unique index on contactid + year.
    Can I do that with the data model?

    Or do I need to write PHP code with a OnDBInsert-check to verifiy if this combination is unique (and how can I throw an error if it's a duplicate)?

     
  • Pierre Goiffon

    Pierre Goiffon - 2018-08-20

    Hello,
    Not sure if it's feasible... and the id is used on all the class hierarchy (same id in each table)...
    What would be the use case ? would a computed field be enough ?

     
  • Jeffrey Bostoen

    Jeffrey Bostoen - 2018-08-21

    We were thinking about a sort of maintenance record, with Year (of maintenance date) + ID of the functional CI being the unique index

     

Log in to post a comment.

MongoDB Logo MongoDB