aurora-mongo
Version:
MongoDBをKeyvのように扱うことができるパッケージです。
47 lines (46 loc) • 1.43 kB
TypeScript
import mongoose from "mongoose";
import { Types, SchemaDefinition, Model } from "mongoose";
/**
*
* @param {string} uri MongoDBとの接続で使用します。
* @example mongo.connect(`mongodb+srv://username:password@hoge.rhaqe.mongodb.net/myFirstDatabase?retryWrites=true&w=majority`)
*/
declare function connect(uri: string): Promise<void>;
interface schemaFields {
key: string;
value: string;
}
declare const schemaFields: SchemaDefinition<schemaFields>;
interface schemaProperties extends schemaFields {
}
interface tempModel extends Model<schemaProperties> {
}
declare class Database {
name: string;
model: tempModel;
/**
*
* @param {string} name MongoDBのモデルの名前。
*/
constructor(name: string);
dget(key: string): Promise<(mongoose.Document<any, any, schemaProperties> & schemaProperties & {
_id: Types.ObjectId;
}) | null>;
get(key: string): Promise<any>;
set(key: string, value: unknown): Promise<null>;
has(key: string): Promise<boolean>;
delete(key: string): Promise<null | undefined>;
clear(): Promise<void>;
/**
*
* @returns {Promise<string[]>} キーの配列が返ってきます。
*/
keys(): Promise<string[]>;
/**
*
* @returns {Promise<any[]>} 値の配列が返ってきます。
*/
values(): Promise<any[]>;
entries(): Promise<any[][]>;
}
export { connect, Database };