New:Microsoft Teams Notifications Are Now Available in Socket.Learn more
Get Started

@canecomext/backend-generator

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

@canecomext/backend-generator

Generates sophistiocated CRUD backend by a datamodel schema destriptor.

latest
Source
npmnpm
Version
1.1.0
Version published
Maintainers
1
Created
Source

Backend generator

Instructions

For implementing code around the generator please see the example project in ./example

To generate code run node ./index.js Eg: node ./index.js ./example/example.json ./example/generated

Upsert feature

Data upsert is not supported by the generator yet. However, upsert feature of Sequelize is ready to be used in custom handler functions.

Further considerations:

  • Hooks are designed to support create/update entity cases
  • For pre hooks the endpoint itself would have to determine if the upsert will execute an update or an insert in order to decide whiche pre hook (create or update) to call. This would mean additional overhead plus a potential race condition scenario if not implemented properly.
  • In case of post hooks there are no such challenges since sequelize is returning if the actual command was an UPDATE or an INSERT

Suggestion:

  • One possible solution could be to cheat a little bit. We could start a transaction -> execute the upsert -> call the pre hooks -> roll back the transaction in case the hooks failed. But this approach would not cover the case where the pre hooks modify the request. In that case we would have to somehow detect that a change happened and execute the upsert a second time with the modified request body after the pre hooks.

FAQs

Package last updated on 25 Jul 2024

Related posts