On Friday, 13 May 2022 at 06:01:29 UTC, rikki cattermole wrote:

On 13/05/2022 5:52 PM, MichaelBi wrote:
struct Camera{
    @name("_id") BsonObjectID id; // represented as "_id" in the database
     string brand;
     string model;
}

the structure is mapping of database field structure. how to resolve?

That code isn't the cause of your issue (its fine, no CTFE needed).

We would need see more of your code surrounding:

        auto uri = environment.get("MONGODB_URI");
        MongoClient conn = connectMongoDB(uri);
        MongoDatabase eqpdb = conn.getDatabase("MbEqpHeroku");

here is the code:

Camera[] showData(){
    auto uri = environment.get("MONGODB_URI");
    MongoClient conn = connectMongoDB(uri);
    MongoDatabase eqpdb = conn.getDatabase("MbEqpHeroku");
    MongoCollection cameras = eqpdb["cameras"];
    Camera[] cs;
    auto results = cameras.find();
    foreach(rec;results) cs ~= deserializeBson!Camera(rec);
    return cs;
}


Reply via email to