Move models to db subdir

This commit is contained in:
jaina heartles 2022-07-24 02:01:17 -07:00
parent 7fc83b6e56
commit b05abf95ac
8 changed files with 37 additions and 8 deletions

View file

@ -3,7 +3,7 @@ const util = @import("util");
const db = @import("./db.zig"); const db = @import("./db.zig");
pub const models = @import("./models.zig"); const models = @import("./db/models.zig");
pub const DateTime = util.DateTime; pub const DateTime = util.DateTime;
pub const Uuid = util.Uuid; pub const Uuid = util.Uuid;

View file

@ -3,7 +3,6 @@ const root = @import("root");
const builtin = @import("builtin"); const builtin = @import("builtin");
const http = @import("http"); const http = @import("http");
const api = @import("./api.zig"); const api = @import("./api.zig");
const models = @import("./models.zig");
const Uuid = @import("util").Uuid; const Uuid = @import("util").Uuid;
pub const auth = @import("./controllers/auth.zig"); pub const auth = @import("./controllers/auth.zig");

View file

@ -3,7 +3,6 @@ const root = @import("root");
const builtin = @import("builtin"); const builtin = @import("builtin");
const http = @import("http"); const http = @import("http");
const api = @import("../api.zig"); const api = @import("../api.zig");
const models = @import("../models.zig");
const Uuid = @import("util").Uuid; const Uuid = @import("util").Uuid;
const utils = @import("../controllers.zig").utils; const utils = @import("../controllers.zig").utils;

View file

@ -1,7 +1,6 @@
const root = @import("root"); const root = @import("root");
const http = @import("http"); const http = @import("http");
const api = @import("../api.zig"); const api = @import("../api.zig");
const models = @import("../models.zig");
const Uuid = @import("util").Uuid; const Uuid = @import("util").Uuid;
const utils = @import("../controllers.zig").utils; const utils = @import("../controllers.zig").utils;

View file

@ -1,7 +1,6 @@
const root = @import("root"); const root = @import("root");
const http = @import("http"); const http = @import("http");
const api = @import("../../api.zig"); const api = @import("../../api.zig");
const models = @import("../../models.zig");
const Uuid = @import("util").Uuid; const Uuid = @import("util").Uuid;
const utils = @import("../../controllers.zig").utils; const utils = @import("../../controllers.zig").utils;

View file

@ -1,6 +1,6 @@
const std = @import("std"); const std = @import("std");
const sql = @import("sql"); const sql = @import("sql");
const models = @import("./models.zig"); const models = @import("./db/models.zig");
const util = @import("util"); const util = @import("util");
const Uuid = util.Uuid; const Uuid = util.Uuid;

View file

@ -1,10 +1,44 @@
const std = @import("std"); const std = @import("std");
const util = @import("util"); const util = @import("util");
const sql = @import("sql");
const ByteArray = @import("./db.zig").ByteArray;
const Uuid = util.Uuid; const Uuid = util.Uuid;
const DateTime = util.DateTime; 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 // Used for documentation purposes
fn Ref(comptime _: type) type { fn Ref(comptime _: type) type {
return Uuid; return Uuid;

View file

@ -4,7 +4,6 @@ const http = @import("http");
const util = @import("util"); const util = @import("util");
const api = @import("./api.zig"); const api = @import("./api.zig");
const models = @import("./models.zig");
const Uuid = util.Uuid; const Uuid = util.Uuid;
const c = @import("./controllers.zig"); const c = @import("./controllers.zig");