Skip to content

Commit

Permalink
updated endpoint to support findById for poi data
Browse files Browse the repository at this point in the history
  • Loading branch information
mauriziopiu committed May 13, 2023
1 parent d20b0d9 commit 1645de4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
10 changes: 4 additions & 6 deletions backend/src/poi-data/poi-data.service.ts
Expand Up @@ -17,14 +17,12 @@ export class PoiDataService {
async findById(id: string) {
const poiCollection = this.mongo.getCollection(this.poiCollectionName);
const poiData = await poiCollection.find().toArray();
const objId = new ObjectId(id); /*
/* used this code to retrieve valid id
poiData.forEach((item) => {
console.log(item._id.toString());
if (item._id.toString() === id) {
console.log('its a match');
}
});*/
const poi = poiCollection.find({ _id: objId });
});
*/
const poi = poiData.find((item) => item._id.toString() === id);
return poi;
}
}
2 changes: 1 addition & 1 deletion frontend/src/app/poi-infobox/poi-infobox.component.ts
Expand Up @@ -7,7 +7,7 @@ import { DataService, POI } from '../shared/data.service';
styleUrls: ['./poi-infobox.component.scss'],
})
export class PoiInfoboxComponent {
@Input() poiId = '645f4a22bfc618b390e3305d';
@Input() poiId = ''; // '645f501d63857bb556fb26b9';
poi!: POI;

constructor(private dataService: DataService) {
Expand Down

0 comments on commit 1645de4

Please sign in to comment.