Source

api/base/BaseUtilities.ts

  1. import { Meteor } from 'meteor/meteor';
  2. import { RadGrad } from '../radgrad/RadGrad';
  3. // import { assertIntegrity } from '../integrity/IntegrityChecker';
  4. // import { Users } from '../user/UserCollection';
  5. /**
  6. * Deletes all documents from all RadGrad collections.
  7. * Checks the integrity of the database before doing the deletion.
  8. * To be used only in testing mode.
  9. * @memberOf api/base
  10. * @throws { Meteor.Error } If there is an integrity issue with the DB prior to deletion.
  11. * @returns true
  12. */
  13. export const removeAllEntities = (): boolean => {
  14. if (Meteor.isTest || Meteor.isAppTest) {
  15. // assertIntegrity(); // this started failing after update to Meteor 1.6.1!
  16. RadGrad.collections.forEach((collection) => {
  17. if (collection.type !== 'AdminProfile') {
  18. collection.collection.remove({});
  19. }
  20. });
  21. // Users is not part of RadGrad collections, so must deal with it individually.
  22. // Users.removeAll();
  23. } else {
  24. throw new Meteor.Error('removeAllEntities not called in testing mode.');
  25. }
  26. return true;
  27. };