Move models to db subdir
This commit is contained in:
parent
7fc83b6e56
commit
b05abf95ac
8 changed files with 37 additions and 8 deletions
|
@ -3,7 +3,7 @@ const util = @import("util");
|
|||
|
||||
const db = @import("./db.zig");
|
||||
|
||||
pub const models = @import("./models.zig");
|
||||
const models = @import("./db/models.zig");
|
||||
pub const DateTime = util.DateTime;
|
||||
pub const Uuid = util.Uuid;
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@ const root = @import("root");
|
|||
const builtin = @import("builtin");
|
||||
const http = @import("http");
|
||||
const api = @import("./api.zig");
|
||||
const models = @import("./models.zig");
|
||||
const Uuid = @import("util").Uuid;
|
||||
|
||||
pub const auth = @import("./controllers/auth.zig");
|
||||
|
|
|
@ -3,7 +3,6 @@ const root = @import("root");
|
|||
const builtin = @import("builtin");
|
||||
const http = @import("http");
|
||||
const api = @import("../api.zig");
|
||||
const models = @import("../models.zig");
|
||||
const Uuid = @import("util").Uuid;
|
||||
|
||||
const utils = @import("../controllers.zig").utils;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
const root = @import("root");
|
||||
const http = @import("http");
|
||||
const api = @import("../api.zig");
|
||||
const models = @import("../models.zig");
|
||||
const Uuid = @import("util").Uuid;
|
||||
|
||||
const utils = @import("../controllers.zig").utils;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
const root = @import("root");
|
||||
const http = @import("http");
|
||||
const api = @import("../../api.zig");
|
||||
const models = @import("../../models.zig");
|
||||
const Uuid = @import("util").Uuid;
|
||||
|
||||
const utils = @import("../../controllers.zig").utils;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
const std = @import("std");
|
||||
const sql = @import("sql");
|
||||
const models = @import("./models.zig");
|
||||
const models = @import("./db/models.zig");
|
||||
const util = @import("util");
|
||||
|
||||
const Uuid = util.Uuid;
|
||||
|
|
|
@ -1,10 +1,44 @@
|
|||
const std = @import("std");
|
||||
const util = @import("util");
|
||||
const sql = @import("sql");
|
||||
|
||||
const ByteArray = @import("./db.zig").ByteArray;
|
||||
const Uuid = util.Uuid;
|
||||
const DateTime = util.DateTime;
|
||||
|
||||
pub fn ByteArray(comptime n: usize) type {
|
||||
return struct {
|
||||
const Self = @This();
|
||||
|
||||
data: [n]u8,
|
||||
|
||||
pub fn bindToSql(self: Self, stmt: sql.PreparedStmt, idx: u15) !void {
|
||||
return stmt.bindBlob(idx, &self.data);
|
||||
}
|
||||
|
||||
pub fn getFromSql(row: sql.Row, idx: u15, _: std.mem.Alloc) !Self {
|
||||
var self: Self = undefined;
|
||||
_ = try row.getBlob(idx, &self.data);
|
||||
return self;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
pub const ByteSlice = struct {
|
||||
const Self = @This();
|
||||
|
||||
data: []const u8,
|
||||
|
||||
pub fn bindToSql(self: Self, stmt: sql.PreparedStmt, idx: u15) !void {
|
||||
return stmt.bindBlob(idx, self.data);
|
||||
}
|
||||
|
||||
pub fn getFromSql(row: sql.Row, idx: u15, alloc: std.mem.Alloc) !void {
|
||||
return Self{
|
||||
.data = try row.getBlobAlloc(idx, alloc),
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
// Used for documentation purposes
|
||||
fn Ref(comptime _: type) type {
|
||||
return Uuid;
|
|
@ -4,7 +4,6 @@ const http = @import("http");
|
|||
const util = @import("util");
|
||||
|
||||
const api = @import("./api.zig");
|
||||
const models = @import("./models.zig");
|
||||
const Uuid = util.Uuid;
|
||||
const c = @import("./controllers.zig");
|
||||
|
||||
|
|
Loading…
Reference in a new issue