@sheetbase/database
v3.0.2
Published
Using Google Sheets as a database.
Downloads
7
Maintainers
Readme
@sheetbase/database
Using Google Sheets as a database.
Install:
npm install --save @sheetbase/database
Usage:
// 1. import module
import { DatabaseModule } from "@sheetbase/database";
// 2. create an instance
export class App {
// the object
databaseModule: DatabaseModule;
// initiate the instance
constructor() {
this.databaseModule = new DatabaseModule(/* options */);
}
}
| Name | Type | Description | | ------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------- | ----------- | | databaseId | string | | | keyFields? | undefined | object | | | security? | boolean | object | | | securityHelpers? | SecurityHelpers | |
The Lib
class.
| Name | Type | Description | | -------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- | ----------- | | databaseContentRoute | DatabaseContentRoute | | | databaseRoute | DatabaseRoute | | | databaseService | DatabaseService | | | filterService | FilterService | | | helperService | HelperService | | | optionService | OptionService | | | securityService | SecurityService | |
| Function | Returns type | Description | | --------------------------------------------------------------------- | ---------------------------- | ------------------------ | | registerRoutes(routeEnabling?, middlewares?) | RouterService<> | Expose the module routes |
Expose the module routes
Parameters
| Param | Type | Description | | ------------- | -------------------------------------------- | ----------- | | routeEnabling | true | DisabledRoutes | | | middlewares | Middlewares | RouteMiddlewares | |
Returns
RouterService<>
DatabaseModule provides REST API endpoints allowing clients to access server resources. Theses enpoints are not exposed by default, to expose the endpoints:
DatabaseModule.registerRoutes(routeEnabling?);
DatabaseModule returns these routing errors, you may use the error code to customize the message:
database/content-no-id
: No doc id.database/no-input
: No path/table/sheet.
| Route | Method | Disabled | Description |
| ------------------------------------------- | -------- | -------- | ----------------------------------------------------------- |
| /database/content | GET
| | Get doc content |
| /database | DELETE
| true
| Delete an item from the database (proxy to: post /database) |
| /database | GET
| true
| Get data from the database |
| /database | PATCH
| true
| Update an item from the database (proxy to: post /database) |
| /database | POST
| true
| Add/update/delete data from database |
| /database | PUT
| true
| Add a new item do the database (proxy to: post /database) |
Get doc content
Request query
| Name | Type | Description | | --------- | --------------------- | ----------- | | docId | string | | | style? | DocsContentStyles | |
Response
object
DISABLED
Delete an item from the database (proxy to: post /database)
Request body
| Name | Type | Description | | -------- | ---------- | ----------- | | path | string | | | table? | string | | | sheet? | string | | | id? | string | | | key? | string | |
Response
void
DISABLED
Get data from the database
Request query
| Name | Type | Description | | -------- | ---------------------- | ----------- | | path? | string | | | table? | string | | | sheet? | string | | | id? | string | | | key? | string | | | type? | 'object' | | | query? | string | | | segment? | string | | | order? | string | | | orderBy? | string | | | limit? | number | | | offset? | number | |
Response
Record<string, unknown> | unknown[]
DISABLED
Update an item from the database (proxy to: post /database)
Request body
| Name | Type | Description | | -------- | ----------- | ----------- | | path | string | | | table? | string | | | sheet? | string | | | id? | string | | | key? | string | | | data? | unknown | |
Response
void
DISABLED
Add/update/delete data from database
Request body
| Name | Type | Description | | ----------- | -------------------------- | ----------- | | path | string | | | table? | string | | | sheet? | string | | | id? | string | | | key? | string | | | data? | unknown | | | increasing? | Record<string, number> | | | clean? | boolean | |
Response
void
DISABLED
Add a new item do the database (proxy to: post /database)
Request body
| Name | Type | Description | | -------- | ----------- | ----------- | | path | string | | | table? | string | | | sheet? | string | | | id? | string | | | key? | string | | | data? | unknown | |
Response
void
License
@sheetbase/database is released under the MIT license.