1

Background:

We need to throw away existing data and import new data each day. The import takes ~15 min, and we don't want the site to be without data during that time. My coworker's solution is to import the new data into a temporary collection, and, once it's done importing, rename the temporary to the production collection name. We save the new data one record at a time, not in a bulk save (as the second related question does).

However, I want to know if an object I'm trying to save to the temporary collection fails uniqueness with another object in that collection (disregarding uniqueness with the production collection). Currently when I call valid? it validates against the production collection, not the temporary collection. I'd like to scope my validations to a particular collection. (As in, if I check uniqueness on name I only want to check against the records in a given collection.)

Question:

How can I pass a collection name through for use with valid?? Or is there another way to validate objects against a non-default collection?

Related questions:

Community
  • 1
  • 1
Lucy Bain
  • 2,496
  • 7
  • 30
  • 45

0 Answers0