3.0.2 • Published 4 years ago

@sheetbase/database v3.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

@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 */);
  }
}
NameTypeDescription
databaseIdstring
keyFields?undefined | object
security?boolean | object
securityHelpers?SecurityHelpers

The Lib class.

NameTypeDescription
databaseContentRouteDatabaseContentRoute
databaseRouteDatabaseRoute
databaseServiceDatabaseService
filterServiceFilterService
helperServiceHelperService
optionServiceOptionService
securityServiceSecurityService
FunctionReturns typeDescription
registerRoutes(routeEnabling?, middlewares?)RouterService<>Expose the module routes

Expose the module routes

Parameters

ParamTypeDescription
routeEnablingtrue | DisabledRoutes
middlewaresMiddlewares | 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.
RouteMethodDisabledDescription
/database/contentGETGet doc content
/databaseDELETEtrueDelete an item from the database (proxy to: post /database)
/databaseGETtrueGet data from the database
/databasePATCHtrueUpdate an item from the database (proxy to: post /database)
/databasePOSTtrueAdd/update/delete data from database
/databasePUTtrueAdd a new item do the database (proxy to: post /database)

Get doc content

Request query

NameTypeDescription
docIdstring
style?DocsContentStyles

Response

object


DISABLED Delete an item from the database (proxy to: post /database)

Request body

NameTypeDescription
pathstring
table?string
sheet?string
id?string
key?string

Response

void


DISABLED Get data from the database

Request query

NameTypeDescription
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

NameTypeDescription
pathstring
table?string
sheet?string
id?string
key?string
data?unknown

Response

void


DISABLED Add/update/delete data from database

Request body

NameTypeDescription
pathstring
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

NameTypeDescription
pathstring
table?string
sheet?string
id?string
key?string
data?unknown

Response

void


License

@sheetbase/database is released under the MIT license.