Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Martin Chang
    @marty1885
    Because var is a keyword in JS
    And CSPs is a template system. It don't automatically quote variables for you.
    Aayush-2492
    @Aayush-2492
    nope wait. I typed const name = [[ nameofVar ]]; not var
    Martin Chang
    @marty1885
    Try: var varName = "[[ nameOfVar ]]";
    Edit: I missed a "
    Aayush-2492
    @Aayush-2492
    It works. Thanks. Can you explain the " "?
    Martin Chang
    @marty1885
    CSP is more of less like PHP. It replaces parts of the .csp document with result generated by your C++ source code and other tags .
    Depending on what nameofVar contains. const name = [[ nameofVar ]]; can render to const name = Hello I'm Martin;. Which is not valid JS
    "" make it const name = "Hello I'm Martin"; which is valid.
    You proverbially want to validate or escape the parameters in the controller to prevent code injection attacks.
    Aayush-2492
    @Aayush-2492
    Oh got it. Its actually giving the rvalue and not the lvalue right
    Martin Chang
    @marty1885
    Not quite...
    CSP looks for certain patterns and replaces them with the appropriate variable. it doesn't know if you are generating a JSON or HTML or JavaScript
    Assuming the variable name is Martin.
    Then the CSP Hello I'm [[ name ]] renders to Hello I'm Martin.
    And var name = [[ name ]]; renders to var name = Martin;.
    Then the JS engine in your browser tries to run that as JS.
    In this context, Martin is a undefined variable name to the JS engine.
    Thus an error.
    Aayush-2492
    @Aayush-2492
    Got it. Thanks for the explanation!
    Alababdiy
    @Alababdiy
    is db->execSqlSync not commit until request finished ?
    Martin Chang
    @marty1885
    execSqlSync runs a given SQL statement and waits for it to finish. It doesn't care about committing or not. You'll want to spawn a transaction using auto transaction db->newTransaction(commit_callback) or the coroutine counterpart.
    Vikhyath-vec
    @Vikhyath-vec
    image.png
    Hey! Does anyone know how to create an array of values in json? I'm trying something like this but it isn't working.
    An Tao
    @an-tao
    please use the append method
    Vikhyath-vec
    @Vikhyath-vec
    So, like Json::Value::append(open_complaints); ?
    An Tao
    @an-tao
    for your case, use open_complaints.append(std::move(complaint));
    Vikhyath-vec
    @Vikhyath-vec
    I'm still getting this error: ‘Array’ is not a member of ‘Json::Value’
    An Tao
    @an-tao
    Json::Value array;
    for(int i=0;i<10;i++) array.append(i);
    Vikhyath-vec
    @Vikhyath-vec
    Oh, thank you for the clarification. Also, how do we parse the JSON array? Can it be like json.get("somename", []).as<vector<some_type>>(); ?
    Vikhyath-vec
    @Vikhyath-vec
    How do we add third-party flags to CMakeLists.txt generated by drogon?
    An Tao
    @an-tao

    Oh, thank you for the clarification. Also, how do we parse the JSON array? Can it be like json.get("somename", []).as<vector<some_type>>(); ?

    you could use iterator to access a array json value; for example:

    for(auto &item: json["array_data"])
    {
        std::cout << item.asString() <<"\n";
    }

    How do we add third-party flags to CMakeLists.txt generated by drogon?

    Just edit the CMakeLists.txt as what you want

    Vikhyath-vec
    @Vikhyath-vec
    for(auto &item: json["array_data"])
    {
        std::cout << item.asString() <<"\n";
    }
    Thank you, will try this out!

    How do we add third-party flags to CMakeLists.txt generated by drogon?

    Just edit the CMakeLists.txt as what you want

    Yes, I have tried doing that but does not work for some reason.
    Specifically, I want to add the flags -lpqxx and -lpq

    An Tao
    @an-tao
    the libpq is a depandecy of drogon and automatically added.
    you could use the orm part of drogon instead of libpqxx
    Vikhyath-vec
    @Vikhyath-vec

    the libpq is a depandecy of drogon and automatically added.

    but when I run the makefile, it still gives me errors which usually come when I don't include the flags

    any specific commands to just add those flags? I'm weak in cmake :(
    João Fernandes
    @0rangeFox
    Hey guys, there's anything is possible to work with mapper's chain interface for coro?
    João Fernandes
    @0rangeFox

    I could do this.

    CoroMapper<Users> usersMapper(app().getFastDbClient());
    usersMapper.limit(1).offset(0);
    
    for (const Users &user : co_await usersMapper.findAll()) {
    }

    But isn't there another way to write on one line like Mapper?

    RamithKS
    @ramithKS
    Hey everyone,
    I’m a beginner to drogon framework and I’m finding it difficult to install the drogon package on Mac .
    Can anyone help me how to install it using vcpkg or using any other way ?
    I tried “vcpkg install drogon” but it’s showing some error at the end .
    Rafał Bugajewski
    @rbugajewski
    @ramithKS You can try the Homebrew version.
    You can install Drogon on macOS with this one command: brew install rbugajewski/drogon/drogon
    I also added head to the formula, so that you can always install the latest development version with the --HEAD command line argument.
    You can also use the official URL now, because the repositories were moved to the organization: brew install drogonframework/drogon/drogon (yes, that’s drogon twice)
    RamithKS
    @ramithKS
    Now I cloned it and installed according to their official documentation but the drogon autocompletes are working only if I copy and paste the drogon file to respected project I’m working on
    Is there any other way ?