database.js
//returns true if entry for a certan id and year/month/day/time is already in database
returns true if entry for a certan id and year/month/day/time is already in database
returns true if entry for a certan id and year / month / day / time is already in database
function checkDuplicateEntry(entry) {
  entries = db.getCollection("entries");
  medicationUpdates = db.getCollection("medicationUpdates");  
  var resultsEntries = entries.chain().find({'$and':[{'pid':entry.pid},{'idate':entry.idate}]}).data();
  var resultsMedicationUpdates = medicationUpdates.chain().find({'$and':[{'pid':entry.pid},{'idate':entry.idate}]}).data();
  if(resultsMedicationUpdates.length>0) {
    console.log("DB debug: Medikations-Updates vorhanden")
  }
  if(resultsEntries.length > 0 || resultsMedicationUpdates.length > 0) {
    return true;
  }else {
    return false;
  }
}
function checkDuplicateEntry ( entry ) { entries = db . getCollection ( "entries" ) ; medicationUpdates = db . getCollection ( "medicationUpdates" ) ; var resultsEntries = entries . chain ( ) . find ( { '$and' : [ { 'pid' : entry . pid } , { 'idate' : entry . idate } ] } ) . data ( ) ; var resultsMedicationUpdates = medicationUpdates . chain ( ) . find ( { '$and' : [ { 'pid' : entry . pid } , { 'idate' : entry . idate } ] } ) . data ( ) ; if ( resultsMedicationUpdates . length > 0 ) { console . log ( "DB debug: Medikations-Updates vorhanden" ) } if ( resultsEntries . length > 0 || resultsMedicationUpdates . length > 0 ) { return true ; } else { return false ; } }
returns true if entry for a certan id and year/month/day/time is already in database
returns true if entry for a certan id and year / month / day / time is already in database