correctly generate nanoid IDs in default clauses
This commit is contained in:
parent
404532012e
commit
3f28680a44
@ -59,7 +59,7 @@ export const AiModelSchema = new Schema<IAiModel>(
|
||||
);
|
||||
|
||||
export const AiProviderSchema = new Schema<IAiProvider>({
|
||||
_id: { type: String, required: true, default: nanoid, unique: true },
|
||||
_id: { type: String, default: () => nanoid() },
|
||||
name: { type: String, required: true },
|
||||
apiType: { type: String, enum: ["ollama", "openai"], required: true },
|
||||
baseUrl: { type: String, required: true },
|
||||
|
||||
@ -16,7 +16,7 @@ export interface IApiClientLog {
|
||||
url: string;
|
||||
}
|
||||
export const ApiClientLogSchema = new Schema<IApiClientLog>({
|
||||
_id: { type: String, default: nanoid, required: true, unique: true },
|
||||
_id: { type: String, default: () => nanoid() },
|
||||
client: { type: String, required: true, index: 1, ref: "ApiClient" },
|
||||
createdAt: {
|
||||
type: Date,
|
||||
|
||||
@ -23,7 +23,7 @@ export interface IApiClient {
|
||||
secret: string;
|
||||
}
|
||||
const ApiClientSchema = new Schema<IApiClient>({
|
||||
_id: { type: String, default: nanoid, required: true, unique: true },
|
||||
_id: { type: String, default: () => nanoid() },
|
||||
createdAt: { type: Date, required: true },
|
||||
updatedAt: { type: Date, required: true },
|
||||
status: {
|
||||
|
||||
@ -11,7 +11,7 @@ export const ChatSessionPinSchema = new Schema<IChatSessionPin>({
|
||||
});
|
||||
|
||||
export const ChatSessionSchema = new Schema<IChatSession>({
|
||||
_id: { type: String, default: nanoid, required: true, unique: true },
|
||||
_id: { type: String, default: () => nanoid() },
|
||||
createdAt: { type: Date, default: Date.now, required: true },
|
||||
lastMessageAt: { type: Date },
|
||||
user: { type: String, required: true, index: 1, ref: "User" },
|
||||
|
||||
@ -13,6 +13,7 @@ import {
|
||||
IChatTurn,
|
||||
IChatTurnStats,
|
||||
} from "@gadget/api";
|
||||
import { nanoid } from "nanoid";
|
||||
|
||||
export const ChatTurnPromptsSchema = new Schema<IChatTurnPrompts>({
|
||||
user: { type: String, required: true },
|
||||
@ -44,6 +45,7 @@ export const ChatSubagentProcessSchema = new Schema<IChatSubagentProcess>({
|
||||
});
|
||||
|
||||
export const ChatTurnSchema = new Schema<IChatTurn>({
|
||||
_id: { type: String, default: () => nanoid() },
|
||||
createdAt: { type: Date, default: Date.now, required: true },
|
||||
user: { type: String, required: true, ref: "User" },
|
||||
project: { type: String, required: false, ref: "Project" },
|
||||
|
||||
@ -5,6 +5,7 @@
|
||||
import { Schema, model } from "mongoose";
|
||||
|
||||
import { GadgetId, IUser } from "@gadget/api";
|
||||
import { nanoid } from "nanoid";
|
||||
|
||||
export interface ICsrfToken {
|
||||
_id: GadgetId;
|
||||
@ -22,6 +23,7 @@ export interface ICsrfToken {
|
||||
}
|
||||
|
||||
const CsrfTokenSchema = new Schema<ICsrfToken>({
|
||||
_id: { type: String, default: () => nanoid() },
|
||||
created: {
|
||||
type: Date,
|
||||
required: true,
|
||||
|
||||
@ -4,6 +4,7 @@
|
||||
|
||||
import { Schema, model } from "mongoose";
|
||||
import { IDroneMonitor, IMemoryMonitor } from "@gadget/api";
|
||||
import { nanoid } from "nanoid";
|
||||
|
||||
export const MemoryMonitorSchema = new Schema<IMemoryMonitor>({
|
||||
count: { type: Number, default: 0, required: true },
|
||||
@ -11,6 +12,7 @@ export const MemoryMonitorSchema = new Schema<IMemoryMonitor>({
|
||||
});
|
||||
|
||||
export const DroneMonitorSchema = new Schema<IDroneMonitor>({
|
||||
_id: { type: String, default: () => nanoid() },
|
||||
registration: { type: String, required: true, index: 1 },
|
||||
timestamp: { type: Date, required: true, index: -1 },
|
||||
memory: {
|
||||
|
||||
@ -7,7 +7,7 @@ import { DroneStatus, IDroneRegistration } from "@gadget/api";
|
||||
import { nanoid } from "nanoid";
|
||||
|
||||
export const DroneRegistrationSchema = new Schema<IDroneRegistration>({
|
||||
_id: { type: String, default: nanoid, required: true, unique: true },
|
||||
_id: { type: String, default: () => nanoid() },
|
||||
createdAt: { type: Date, required: true },
|
||||
updatedAt: { type: Date, required: false },
|
||||
user: { type: String, ref: "User", required: true },
|
||||
|
||||
@ -17,7 +17,7 @@ export interface IEmailLog {
|
||||
messageId: string;
|
||||
}
|
||||
export const EmailLogSchema = new Schema<IEmailLog>({
|
||||
_id: { type: String, default: nanoid, required: true, unique: true },
|
||||
_id: { type: String, default: () => nanoid() },
|
||||
created: { type: Date, default: Date.now, required: true, index: -1 },
|
||||
from: { type: String, required: true },
|
||||
to: { type: String, required: true },
|
||||
|
||||
@ -4,6 +4,7 @@
|
||||
|
||||
import { Schema, model } from "mongoose";
|
||||
import { GadgetId, IUser } from "@gadget/api";
|
||||
import { nanoid } from "nanoid";
|
||||
|
||||
export enum EmailVerificationStatus {
|
||||
Pending = "pending",
|
||||
@ -12,12 +13,14 @@ export enum EmailVerificationStatus {
|
||||
}
|
||||
|
||||
export interface IEmailVerification {
|
||||
_id: GadgetId;
|
||||
createdAt: Date;
|
||||
user: IUser | GadgetId;
|
||||
code: string;
|
||||
status: EmailVerificationStatus;
|
||||
}
|
||||
export const EmailVerificationSchema = new Schema<IEmailVerification>({
|
||||
_id: { type: String, default: () => nanoid() },
|
||||
createdAt: { type: Date, required: true, default: Date.now },
|
||||
user: { type: String, required: true, index: 1, ref: "User" },
|
||||
code: { type: String, required: true, unique: true },
|
||||
|
||||
@ -8,7 +8,7 @@ import { nanoid } from "nanoid";
|
||||
import { IIdeSession } from "@gadget/api";
|
||||
|
||||
const IdeSessionSchema = new Schema<IIdeSession>({
|
||||
_id: { type: String, default: nanoid, required: true, unique: true },
|
||||
_id: { type: String, default: () => nanoid() },
|
||||
createdAt: { type: Date, default: Date.now, required: true },
|
||||
user: { type: String, required: true, ref: "User" },
|
||||
});
|
||||
|
||||
@ -5,8 +5,10 @@
|
||||
import { Schema, model } from "mongoose";
|
||||
|
||||
import { ProjectStatus, IProject } from "@gadget/api";
|
||||
import { nanoid } from "nanoid";
|
||||
|
||||
export const ProjectSchema = new Schema<IProject>({
|
||||
_id: { type: String, default: () => nanoid() },
|
||||
createdAt: { type: Date, default: Date.now, required: true },
|
||||
user: { type: String, required: true, index: 1, ref: "User" },
|
||||
status: { type: String, enum: ProjectStatus, required: true },
|
||||
|
||||
@ -18,7 +18,7 @@ export const UserFlagsSchema = new Schema<IUserFlags>(
|
||||
);
|
||||
|
||||
export const UserSchema = new Schema<IUser>({
|
||||
_id: { type: String, default: nanoid, required: true, unique: true },
|
||||
_id: { type: String, default: () => nanoid() },
|
||||
email: { type: String, required: true },
|
||||
email_lc: { type: String, required: true, lowercase: true, unique: true },
|
||||
passwordSalt: { type: String, required: true, select: false },
|
||||
|
||||
@ -16,7 +16,7 @@ export interface IWebToken {
|
||||
token: string;
|
||||
}
|
||||
export const WebTokenSchema = new Schema<IWebToken>({
|
||||
_id: { type: String, default: nanoid, required: true, unique: true },
|
||||
_id: { type: String, default: () => nanoid() },
|
||||
created: { type: Date, required: true, index: 1 },
|
||||
expires: { type: Date, required: true, index: -1 },
|
||||
user: { type: String, required: true, ref: "User" },
|
||||
|
||||
@ -25,7 +25,7 @@ export interface IWebVisit {
|
||||
metroCode?: number;
|
||||
}
|
||||
export const WebVisitSchema = new Schema<IWebVisit>({
|
||||
_id: { type: String, default: nanoid, required: true, unique: true },
|
||||
_id: { type: String, default: () => nanoid() },
|
||||
created: { type: Date, default: Date.now },
|
||||
url: { type: String, required: true },
|
||||
user: { type: String, index: 1, ref: "User" },
|
||||
|
||||
Loading…
Reference in New Issue
Block a user