@soapjs/soap-node-mysql
TypeScript icon, indicating that this package has built-in type declarations

0.0.1 • Public • Published

MySql for SoapJS

This package provides MySql integration for the SoapJS framework, enabling seamless interaction with MySql databases and ensuring that your data access layer is clean, efficient, and scalable.

Features

  • Easy-to-use MySql collections and query factories.
  • Integration with the SoapJS framework for structured, clean architecture.
  • Support for MySql operations such as find, insert, update, and delete.
  • Custom error handling to improve debugging and error resolution.

Installation

Remember to have mysql2 and @soapjs/soap installed in your project in which you want to use this package.

Install the package using npm:

npm install @soapjs/soap-node-mysql

Usage

  1. Import the necessary components from the package:

    import {
      MySqlCollection,
      MySqlConfig,
      MySqlQueryFactory,
      MySqlSource,
    } from '@soapjs/soap-node-mysql';
  2. Set up your MySql configuration:

    const config = new MySqlConfig({
      database: 'yourDatabase',
      hosts: ['localhost'],
      ports: ['27017'],
      user: 'yourUser',
      password: 'yourPassword'
      // additional config parameters
    });
  3. Create a new MySqlSource instance:

    const mysqlSource = await MySqlSource.create(config);
  4. Utilize MySqlQueryFactory for building queries and aggregations:

    const queryFactory = new MySqlQueryFactory();
    const params = FindParams.create({
      where: new Where().valueOf('customer').isEq(userId)
    });
    const queryParts = queryFactory.createFindQuery(params);
  5. Use MySqlCollection to perform database operations:

    const collection = new MySqlCollection<MyDocumentType>(mysqlSource, 'myCollectionName');
    const documents = await collection.find(queryParts);
    /*
    // You can also use a raw SQL query as a string. Then remember to validate this query beforehand
    const documents = await collection.find(`SELECT * FROM ${collection.collectionName} ...`);
    */

Documentation

For detailed documentation and additional usage examples, visit SoapJS documentation.

Issues

If you encounter any issues, please feel free to report them here.

Contact

For any questions, collaboration interests, or support needs, you can contact us through the following:

License

@soapjs/soap-node-mysql is MIT licensed.

Readme

Keywords

none

Package Sidebar

Install

npm i @soapjs/soap-node-mysql

Weekly Downloads

2

Version

0.0.1

License

MIT

Unpacked Size

24.9 kB

Total Files

20

Last publish

Collaborators

  • rkamysz