Skip to content

Commit

Permalink
Fixing insertion issue due to existing documents
Browse files Browse the repository at this point in the history
  • Loading branch information
fmsouza committed Aug 19, 2015
1 parent 1c702ae commit d4990ba
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/core/database/driver/mongodb/mongoCollection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ class MongoCollection<T> implements ICollection<T>{
*/
public remove(query: any = {}): void {
query = this.map.prepareToInput(query);
this.context.remove(query, (error, output)=>{ if(error) throw error; });
Sync.promise(this.context, this.context.remove, query);
//this.context.remove(query, (error, output)=>{ if(error) throw error; });
}

/**
Expand Down
7 changes: 6 additions & 1 deletion src/dataAccess/busDataAccess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,17 @@ class BusDataAccess implements IDataAccess {
if(bus===null || bus===undefined) return;
delete bus._id; // Is being firstly created, will never have an id here.
bus.line += "";
busBulk.find({ order: bus.getOrder() }).replaceOne(bus, true);
busBulk.insert(bus);
historyBulk.insert(bus);
}, this);
try {
this.bus.remove();
busBulk.execute();
historyBulk.execute();
//var busOutput = busBulk.execute().toJSON();
//var historyOutput = historyBulk.execute().toJSON();
//this.logger.info("Buses inserted to search: "+busOutput.nInserted);
//this.logger.info("Buses inserted to history: "+historyOutput.nInserted);
} catch (e) {
this.logger.error(e);
}
Expand Down

0 comments on commit d4990ba

Please sign in to comment.