feat: mongodb readyState
This commit is contained in:
@ -2,10 +2,13 @@ import { logger } from '@nuxt/kit'
|
||||
import mongoose from 'mongoose'
|
||||
import type { NuxtDevtoolsServerContext, ServerFunctions } from '../types'
|
||||
|
||||
export function setupDatabaseRPC({ nuxt, options }: NuxtDevtoolsServerContext): any {
|
||||
export function setupDatabaseRPC({ options }: NuxtDevtoolsServerContext): any {
|
||||
mongoose.connect(options.uri, options.options)
|
||||
|
||||
return {
|
||||
async readyState() {
|
||||
return mongoose.connection.readyState
|
||||
},
|
||||
async createCollection(name: string) {
|
||||
return await mongoose.connection.db.createCollection(name)
|
||||
},
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
export interface ServerFunctions {
|
||||
// Database - collections
|
||||
readyState(): Promise<any>
|
||||
createCollection(name: string): Promise<any>
|
||||
listCollections(): Promise<any>
|
||||
getCollection(name: string): Promise<any>
|
||||
@ -27,6 +28,6 @@ export interface Collection {
|
||||
}
|
||||
|
||||
export interface Resource {
|
||||
type: string
|
||||
type: 'index' | 'create' | 'show' | 'put' | 'delete'
|
||||
by?: string
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user