From 324872564c48417bee7117c51ba954667ee89441 Mon Sep 17 00:00:00 2001 From: Vincent Rischmann Date: Sat, 14 Dec 2024 01:33:00 +0100 Subject: readme: fix examples --- README.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'README.md') diff --git a/README.md b/README.md index 458d2e2..4938f76 100644 --- a/README.md +++ b/README.md @@ -469,7 +469,9 @@ Take the following code: var stmt = try db.prepare("SELECT id FROM user WHERE age > ? AND age < ? AND weight > ?"); defer stmt.deinit(); -const rows = try stmt.all(usize, .{}, .{ +const allocator = std.heap.page_allocator; // Use a suitable allocator + +const rows = try stmt.all(usize, allocator, .{}, .{ .age_1 = 10, .age_2 = 20, }); @@ -504,7 +506,9 @@ For example, take the same code as above but now we also bind the last parameter var stmt = try db.prepare("SELECT id FROM user WHERE age > ? AND age < ? AND weight > ?"); defer stmt.deinit(); -const rows = try stmt.all(usize, .{ .allocator = allocator }, .{ +const allocator = std.heap.page_allocator; // Use a suitable allocator + +const rows = try stmt.all(usize, allocator, .{}, .{ .age_1 = 10, .age_2 = 20, .weight = false, @@ -519,7 +523,7 @@ We can make sure the bind parameters have the right type if we rewrite the query var stmt = try db.prepare("SELECT id FROM user WHERE age > ? AND age < ? AND weight > ?{usize}"); defer stmt.deinit(); -const rows = try stmt.all(usize, .{ .allocator = allocator }, .{ +const rows = try stmt.all(usize, allocator, .{}, .{ .age_1 = 10, .age_2 = 20, .weight = false, -- cgit v1.2.3