用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/diegosouzapw/awesome-omni-skill --skill mongodb-with-mongoose命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
Token-efficient tracking for AI orchestration. CLI-first for status updates (~50 tokens), agent fallback for complex ops (~1KB). Use when: updating task status, querying blockers, creating progress files, validating phases.
AshAi extension guidelines for integrating AI capabilities with Ash Framework. Use when implementing vectorization/embeddings, exposing Ash actions as LLM tools, creating prompt-backed actions, or setting up MCP servers. Covers semantic search, LangChain integration, and structured outputs.
This skill should be used when solving hard questions, complex architectural problems, or debugging issues that benefit from GPT-5 Pro or GPT-5.1 thinking models with large file context. Use when standard Claude analysis needs deeper reasoning or extended context windows.
基于 SOC 职业分类
正在显示 SKILL.md
| name | MongoDB with Mongoose |
| description | Database patterns for user data and credentials storage |
This skill covers MongoDB database operations for the autoclaim bot.
// src/database.ts
import mongoose from "mongoose";
export async function connectDatabase() {
const uri = process.env.MONGODB_URI;
if (!uri) throw new Error("MONGODB_URI not set");
await mongoose.connect(uri);
console.log("Connected to MongoDB");
}
// src/models/user.ts
import { Schema, model, Document } from "mongoose";
interface IHoyolabCredentials {
ltoken: string;
ltuid: string;
cookieToken?: string;
games: string[];
}
interface IEndfieldCredentials {
skOauthCredKey: string;
gameId: string;
server: string;
}
interface IUser extends Document {
discordId: string;
hoyolab?: IHoyolabCredentials;
endfield?: IEndfieldCredentials;
settings: {
notifications: boolean;
autoClaimEnabled: boolean;
};
lastClaim?: Date;
createdAt: Date;
updatedAt: Date;
}
const userSchema = new Schema<IUser>(
{
discordId: { type: String, required: true, unique: true, index: true },
hoyolab: {
ltoken: { type: String },
ltuid: { type: String },
cookieToken: { type: String },
games: [{ type: String }]
},
endfield: {
skOauthCredKey: { type: String },
gameId: { type: String },
server: { type: String }
},
settings: {
notifications: { type: Boolean, default: true },
autoClaimEnabled: { type: Boolean, default: true }
},
lastClaim: { type: Date }
},
{ timestamps: true }
);
export const User = model<IUser>("User", userSchema);
async function findOrCreateUser(discordId: string) {
let user = await User.findOne({ discordId });
if (!user) {
user = await User.create({ discordId });
}
return user;
}
async function updateHoyolabCredentials(discordId: string, credentials: IHoyolabCredentials) {
return User.findOneAndUpdate({ discordId }, { $set: { hoyolab: credentials } }, { new: true, upsert: true });
}
async function getActiveUsers() {
return User.find({
"settings.autoClaimEnabled": true,
$or: [{ "hoyolab.ltoken": { $exists: true } }, { "endfield.skOauthCredKey": { $exists: true } }]
});
}
async function deleteUserData(discordId: string) {
return User.deleteOne({ discordId });
}
async function updateLastClaim(discordId: string) {
return User.findOneAndUpdate({ discordId }, { $set: { lastClaim: new Date() } }, { new: true });
}
const claimHistorySchema = new Schema({
discordId: { type: String, required: true, index: true },
game: { type: String, required: true },
success: { type: Boolean, required: true },
message: { type: String },
rewards: [
{
name: String,
count: Number,
icon: String
}
],
claimedAt: { type: Date, default: Date.now }
});
// Index for efficient queries
claimHistorySchema.index({ discordId: 1, claimedAt: -1 });
export const ClaimHistory = model("ClaimHistory", claimHistorySchema);
lean() for read-only queries// Encrypt sensitive data before storing
import crypto from "crypto";
const ENCRYPTION_KEY = process.env.ENCRYPTION_KEY!;
function encrypt(text: string): string {
const iv = crypto.randomBytes(16);
const cipher = crypto.createCipheriv("aes-256-cbc", Buffer.from(ENCRYPTION_KEY, "hex"), iv);
let encrypted = cipher.update(text);
encrypted = Buffer.concat([encrypted, cipher.final()]);
return iv.toString("hex") + ":" + encrypted.toString("hex");
}
function decrypt(text: string): string {
const parts = text.split(":");
const iv = Buffer.from(parts[0], "hex");
const encrypted = Buffer.(parts[], );
decipher = crypto.(, .(, ), iv);
decrypted = decipher.(encrypted);
decrypted = .([decrypted, decipher.()]);
decrypted.();
}