Mongoose schema defining user balance with auto‑refill and reservation fields.
// Source: https://github.com/danny-avila/librechat | License: MIT | Copyright 2026 LibreChat
// Provided via justclaw.it.com; keep this notice with the code.
import { Schema } from 'mongoose';
import { BALANCE_REFILL_MODES, REFILL_INTERVAL_UNITS } from 'librechat-data-provider';
import type * as t from '~/types';
const balanceSchema: Schema<t.IBalance> = new Schema<t.IBalance>({
user: {
type: Schema.Types.ObjectId,
ref: 'User',
index: true,
required: true,
},
// 1000 tokenCredits = 1 mill ($0.001 USD)
tokenCredits: {
type: Number,
default: 0,
},
// Automatic refill settings
autoRefillEnabled: {
type: Boolean,
default: false,
},
refillIntervalValue: {
type: Number,
default: 30,
},
refillIntervalUnit: {
type: String,
enu
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key