opencart-sql-api
v1.1.3
Published
Opencart API - Wrapper for SQL
Downloads
10
Maintainers
Readme
Opencart SQL API
Package making it much easier to access in programmatic way Opencart data
Usage
npm install --save opencart-sql-api
const Api = require('opencart-sql-api')
const Products = require('opencart-sql-api/repository/Products')
const myStoreDB = new Api({
database: {
connection: {
host: 'localhost',
port: 3306,
user: 'user',
password: 'my-secret-pass',
database: 'my_store_db',
},
tablePrefix: 'oc_'
},
})
const productsRepository = new Products(myStore)
const myProducts = productsRepository.list({ page: 1, limit: 50 })
myProducts.then(products => {
console.log(products)
})
Repositories
Categories
const OpencartApi = require('opencart-sql-api')
const Categories = require('opencart-sql-api/repository/Categories')
const api = new OpencartApi(config)
const categories = new Categories(api)
List
List all categories
categories.list({
page: 1,
limit: 50,
query: {
status: 1
},
})
Get
Gets a category by ID
categories.get(1)
Customers
const OpencartApi = require('opencart-sql-api')
const Customers = require('opencart-sql-api/repository/Customers')
const api = new OpencartApi(config)
const customers = new Customers(api)
List
customers.list({ page: 1, limit: 50, query: { status: 1 }})
Get
customers.get(1)