0.0.3 • Published 8 months ago
@crtxio/database v0.0.3
@crtxio/database
@crtxio/database is a Nuxt3 layer which provides Nuxt 3 composables to connect to and fetch data from databases.
Setup
Make sure to install the dependencies:
npm install --save @crtxio/database
or
yarn add @crtxio/database
Add the dependency to your extends
in nuxt.config
:
defineNuxtConfig({
extends: [
'@crtxio/database'
]
})
How to use it
Composables
// Query first match in a collection:
await getFirstMatch(url: string, admin: string, password: string, collection: string, searchQuery: string);
// Query last match in a collection:
await getLastMatch(url: string, admin: string, password: string, collection: string, searchQuery: string);
// Query all matches in a collection
await getAllMatches(url: string, admin: string, password: string, collection: string, searchQuery: string, batch?: number);
// Query all items in a collection:
await getAllRecords(url: string, admin: string, password: string, collection: string);
// Query match by id:
await getMatchById(url: string, admin: string, password: string, collection: string, id: string);
//Update match by id:
await updateMatchById(url: string, admin: string, password: string, collection: string, id: string, data: any);
// Delete match by id:
await deleteMatchById(url: string, admin: string, password: string, collection: string, id: string);