# motionx-portal-package

> ```sh > This lib for manage database of motionx studio. ```

Latest version **1.0.58** (published 2025-05-29) · 0 weekly downloads

## Install

```sh
npm install motionx-portal-package
pnpm add motionx-portal-package
yarn add motionx-portal-package
bun add motionx-portal-package
```

## Health

**Score 25/100 (F)** — status: maintenance-mode.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.58 |
| Published | 2025-05-29 |
| First published | 2023-02-03 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 645.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | deltaforce2022 |

## Links

- npm: https://www.npmjs.com/package/motionx-portal-package
- npm.io page: https://npm.io/package/motionx-portal-package

## Recent versions

- 1.0.58 (latest) — 2025-05-29
- 1.0.57 — 2025-05-29
- 1.0.56 — 2023-06-09
- 1.0.55 — 2023-03-16
- 1.0.54 — 2023-03-08
- 1.0.53 — 2023-03-03
- 1.0.52 — 2023-03-03
- 1.0.51 — 2023-03-01
- 1.0.50 — 2023-03-01
- 1.0.49 — 2023-03-01
- 1.0.48 — 2023-03-01
- 1.0.47 — 2023-03-01
- 1.0.46 — 2023-03-01
- 1.0.45 — 2023-03-01
- 1.0.44 — 2023-03-01
- … 44 more at https://npm.io/package/motionx-portal-package/versions

## README

# motionx-portal-package [![npm version](https://badge.fury.io/js/motionx-portal-package.svg)](https://badge.fury.io/js/motionx-portal-package)

```sh
> This lib for manage database of motionx studio.
```

Install with [npm](https://www.npmjs.com/)

```sh
$ npm i motionx-portal-package --save
```

## Usage initialize

```js
const { StationModel } = require("motionx-portal-package");
//If you need management with Stations table.

//Call initialize func and set sql connect to this. 1 only

/**
 * DatabaseConection Mysq.Connection in Config.js
 */
StationModel.SetConnectDatabase(DatabaseConection);
```

## Example

### Create new station

```js
const {
  StationModel,
  STATE_CODE_STATION,
  STATE_CODE_EVENT_MANAGEMENT,
  STATE_CODE_VOID,
} = require("motionx-portal-package");
// If you need management with Stations table.

// Create new multi station
const newStation = new StationModel({
  refProductId, // Require!
  refCompanyId, // Require!
  refOrderDealId: null,
  refStoreId: null,
  serialNumber, // Require!
  stationNameCustom, // Require!
  datetimeStation, // Require!
  datetimeNotify, // Require!
  datetimeExp, // Require!
  stateCode: STATE_CODE_STATION.ACTIVED, // Require!
  refInvoiceId, // Require!
  refCommissionId, // Require!
  isArrears, // Require!
  lastSynced: null,
  refManageUserId, // Require!
  lastEventCode: STATE_CODE_EVENT_MANAGEMENT.CREATE_STATION, // Require
  isVoidStation: STATE_CODE_VOID.DON_T_VOID, // Require
  voidAuth: null,
  voidComment: null,
  typeCodeStation: typeCodeStation, // Require
});

// [INSERT INTO STATION VALUES (...), (...)]
const result = await StationModel.CREATE_MULTI_STATION([newStation]);
console.log(result); // --> Array Object of station
```

### Query station by id

```js
const { StationModel } = require("motionx-portal-package");
// If you need management with Stations table.

// [SELECT * FROM stations WHERE _id = `Id`]
const result = await StationModel.FIND_STATION_BY_ID(Id);
console.log(result); // --> 1 Object of station
```

### Query station by condition

```js
const {
  StationModel,
  MAKE_LIMIT_OFFSET,
  STATE_CODE_STATION,
  MAKE_OPERATOR,
} = require("motionx-portal-package");
// If you need management with Stations table.

//If you want OR use EQUAL_OR
var condition = {
  [MAKE_OPERATOR.EQUAL_AND("stations.isVoidStation")]: 1,
  [MAKE_OPERATOR.EQUAL_AND("stations.stateCode")]: STATE_CODE_STATION.VOIDED,
};

// limitOfPage is limit record per page
// offset is current offset
const limitOffset = MAKE_LIMIT_OFFSET(/*limitOfPage*/ 10, /*offset*/ 0);
// [ SELECT * FROM stations WHERE stations.isVoidStation = 1 AND stations.stateCode = 0 OFFSET 0 LIMIT 1]
const result = await StationModel.FIND_STATION_BY_FIELD(condition, limitOffset);
console.log(result); // --> Array Object of station
```

### Update station by id

```js
const {
  StationModel,
  MAKE_LIMIT_OFFSET,
  STATE_CODE_STATION,
  MAKE_OPERATOR,
} = require("motionx-portal-package");
// If you need management with Stations table.

const stationUpdate = {
  serialNumber: value,
};

//[UPDATE STATION SET serialNumber = `value` WHERE _id = `Id`]
const result = await StationModel.UPDATE_STATION_BY_ID(Id, station);
console.log(result); // --> 1 Object of station
```

### Condition Option `MAKE_OPERATOR`

```sh
NOT_AND                     `-> [WHERE condition != '' AND ...]`
NOT_OR                      `-> [WHERE condition != '' OR ... ]`
EQUAL_AND                   `-> [WHERE condition = '' AND ... ]`
EQUAL_OR                    `-> [WHERE condition = '' OR ...  ]`
MORE_THAN_EQUAL_AND         `-> [WHERE condition >= '' AND ...]`
MORE_THAN_EQUAL_OR
LESS_THAN_EQUAL_AND         `-> [WHERE condition <= '' AND ...]`
LESS_THAN_EQUAL_OR
WHERE_IN_AND, WHERE_IN_OR,  `-> [WHERE condition IN() OR ...  ]`
... -> can look in ref code
```

### Handling Errors
```js
try{
  /** Call Model Management Function will catch if Error */
}catch(error){
  console.log(error) // Error case
}
```

## Other tbl management

- WareHouseModel
- UserModel
- UserGmailHistoryModel
- TransactionPaymentModel
- StoreModel
- StationModel
- StationWareHouseModel
- PromotionModel
- PromotionPlayerModel
- ProductModel
- ProductTypeModel
- PriceTransactionModel
- PermissionModel
- OrderProductCardModel
- OrderPaymentModel
- OrderDealCardModel
- LogResetPasswordModel
- LogMapPlayedModel
- LogPlayedModel
- LogNotifyEventModel
- LogEventSimulatorModel
- LogEventManagementModel
- LogEndSessionModel
- LisenceModel
- InvoiceCommissionModel
- InvoicePromotionPlayedModel
- InvoiceStationModel
- ImageResouceModel
- EmailThreadModel
- EmailMessageModel
- DLCOrderModel
- DLCProductModel
- DLCProductRateModel
- CountryModel
- ContactCustCompanyModel
- CompanyModel
- CommissionModel
- EmailMessageTemplateModel

---
_Source: https://npm.io/package/motionx-portal-package · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
