0.0.53 • Published 1 year ago

oute-services-db-handler-sdk v0.0.53

Weekly downloads
-
License
-
Repository
-
Last release
1 year ago

This module expose helper functions

  • Initialization
  var db_handler_instance = require("oute-services-db-handler-sdk")
  • Get client for db connection
  state = {}
  db_config = {db_type: "postgres", configs: []}
  options = {logging: false} //additional options
  await db_handler_instance.getClient(state, db_config, options)
  • Execute query on the client
  query = "select 1 as const"
  db_options = {logging: false}
  query_options = {type: "SELECT"}
  db_config = {db_type: "postgres", configs: []}
  state = {}
  client_info = await db_handler_instance.getClient(state, db_config)
  await db_handler_instance.executeQuery(client_info?.db_client, client_info?.db_type, query, options)
  • Disconnect client
  state = {}
  db_config = {db_type: "postgres", configs: []}
  client_info = await db_handler_instance.getClient(state, db_config)
  await db_handler_instance.disconnect(client_info?.db_client, client_info?.db_type)
  • Sync db models
  state = {}
  db_config = {db_type: "postgres", configs: []}
  options = {logging: false} //additional options
  model_dir = __dirname + "/models" //schema name will auto append to this path
  sync_info = await db_handler_instance.syncDbModel(state, db_config, options, model_dir)

CRUD operation

  • Generate model
  state = {}
  db_config = {}
  table_config = {}
  fields_config = []
  options = {type: "SELECT", logging: false}
  client_info = await db_handler_instance.getClient(state, db_config, options)
  model_info = await db_handler_instance.getModel(client_info?.db_client, client_info?.orm_type, client_info?.orm_misc?.data_types, client_info?.db_type, table_config, fields_config)
  • Insert single row
  orm_type = "sequelize"
  instance = sequelize.define('users', {})
  data = {user_id: 1}
  await db_handler_instance.crud.insert(orm_type, instance, data)
  • Find all
  orm_type = "sequelize"
  instance = sequelize.define('users', {})
  options = { where: {"user_id": "s1"}}
  await db_handler_instance.crud.find(orm_type, instance, options)
  • update all
  orm_type = "sequelize"
  instance = sequelize.define('users', {})
  update = {first_name: "update"}
  options = { where: {"user_id": "s1"}}
  await db_handler_instance.crud.updateMany(orm_type, instance, update, options)
  • delete all
  orm_type = "sequelize"
  instance = sequelize.define('users', {})
  options = { where: {"user_id": "s1"}}
  await db_handler_instance.crud.deleteMany(orm_type, instance, options)
0.0.40

1 year ago

0.0.41

1 year ago

0.0.42

1 year ago

0.0.43

1 year ago

0.0.44

1 year ago

0.0.45

1 year ago

0.0.46

1 year ago

0.0.47

1 year ago

0.0.37

1 year ago

0.0.38

1 year ago

0.0.39

1 year ago

0.0.30

1 year ago

0.0.31

1 year ago

0.0.32

1 year ago

0.0.33

1 year ago

0.0.34

1 year ago

0.0.35

1 year ago

0.0.36

1 year ago

0.0.26

1 year ago

0.0.27

1 year ago

0.0.28

1 year ago

0.0.29

1 year ago

0.0.23

1 year ago

0.0.24

1 year ago

0.0.25

1 year ago

0.0.51

1 year ago

0.0.52

1 year ago

0.0.53

1 year ago

0.0.50

1 year ago

0.0.48

1 year ago

0.0.49

1 year ago

0.0.22

1 year ago

0.0.21

1 year ago

0.0.20

1 year ago

0.0.18

1 year ago

0.0.19

1 year ago

0.0.17

1 year ago

0.0.16

1 year ago

0.0.11

1 year ago

0.0.12

1 year ago

0.0.13

1 year ago

0.0.14

1 year ago

0.0.15

1 year ago

0.0.10

1 year ago

0.0.9

1 year ago

0.0.8

1 year ago

0.0.7

1 year ago

0.0.5

1 year ago

0.0.6

1 year ago

0.0.3

1 year ago

0.0.4

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago