Help, in vibe.d, how to get configure var of mongodb in heroku?
MichaelBi
shunjie.bi at gmail.com
Fri May 13 05:52:53 UTC 2022
On Friday, 13 May 2022 at 05:41:33 UTC, rikki cattermole wrote:
> On 13/05/2022 5:18 PM, MichaelBi wrote:
>> i have code here:
>> auto uri = environment.get("MONGODB_URI");
>> MongoClient conn = connectMongoDB(uri);
>> MongoDatabase eqpdb = conn.getDatabase("MbEqpHeroku");
>>
>> the "MONGODB_URI" showed above already put into heroku's app
>> config as the 'key' and there is a paired 'value'. so the uri
>> is to extract the value which is to use for app to establish
>> mongodb connection.
>>
>> and above code with error msg here: Error: `getenv` cannot be
>> interpreted at compile time, because it has no available
>> source code
>
> That part of the code is probably fine.
>
> Basically you have to be careful that:
>
> auto uri = environment.get("MONGODB_URI");
>
> Isn't being executed during compilation.
>
> Stuff that typically cause this is anything that initializes a
> variable.
>
> Globals:
>
> shared Foo foo = Foo(...);
>
> Class fields:
>
> class Foo {
> Bar bar = Bar(...);
> }
yes, then should be this?
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?
More information about the Digitalmars-d-learn
mailing list