Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update README examples for tql 0.1 behaviour #30

Open
jq-rs opened this issue Feb 15, 2018 · 3 comments
Open

Update README examples for tql 0.1 behaviour #30

jq-rs opened this issue Feb 15, 2018 · 3 comments

Comments

@jq-rs
Copy link

jq-rs commented Feb 15, 2018

Current (15/2/2018) README example does not work properly with 0.1. Connection-parameter is missing. SQlite example is also missing. Please add new examples which work out-of-the box on nightly and stable.

@antoyo
Copy link
Owner

antoyo commented Feb 16, 2018

I've updated the README:
I hope it clarifies things.
Also, could you please open an issue with the code causing an error with SQLite?
Thank you.

@antoyo antoyo closed this as completed Feb 16, 2018
@jq-rs
Copy link
Author

jq-rs commented Mar 1, 2018

Unfortunately, I think the examples are still incorrect in the master branch as e.g. the connection parameter is missing:

fn main() {
    let connection = get_connection();

    // We first create the table.
    // (You might not want to execute this query every time.)
    let _ = sql!(Model.create());

    // Insert a row in the table.
    let text = String::new();
    let id = sql!(Model.insert(text = text, date_added = Utc::now())).unwrap();

    // Update a row.
    let result = sql!(Model.get(id).update(text = "new-text"));

    // Delete a row.
    let result = sql!(Model.get(id).delete());

    // Query some rows from the table:
    // get the last 10 rows sorted by date_added descending.
    let items = sql!(Model.sort(-date_added)[..10]);

@antoyo
Copy link
Owner

antoyo commented Mar 1, 2018

Where is it missing?
We can see the connection paramater at the end of this section.

@antoyo antoyo reopened this Mar 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants