2.1.2 • Published 3 months ago

js-php-mysql-crud-api v2.1.2

Weekly downloads
-
License
MIT
Repository
github
Last release
3 months ago

JavaScript PHP MySQL CRUD API

This is a minimal JavaScript wrapper for the incredible PHP CRUD API by Maurits van der Schee.

🚨 No more maintenance - you can use https://github.com/thipages/js-crud-api

Installation

  1. Install Docker and Node.js

  2. Create a new app project:

    npm create vite
  3. Add a PHP backend

    npx add-php-backend
  4. Install this module:

    npm install js-php-mysql-crud-api

Usage

import useAPI from 'js-php-mysql-crud-api'

const api = useAPI()

(async () => {

  // Add some records to the table
  await api.create('tasks', { title: 'First' })
  await api.create('tasks', { title: 'Second' })        
  await api.create('tasks', { title: 'Third' })

  // Retrieve a list of all records
  const records = await api.list('tasks')

  // Log them to the console
  console.log(records)

})()

Methods

Change the API endpoint if required (default /api.php):

  • setEndpoint(endpoint)

According to the CRUD + List operations:

  • create(table, item)
  • read(table, key)
  • update(table, key, item)
  • delete(table, key)
  • list(path)

According to the Database Authentication operations:

  • me()
  • register(username, password)
  • login(username, password)
  • password(username, password, newPassword)
  • logout()

Request function for Custom Controller:

  • request(path, options = {})
2.1.2

3 months ago

2.1.1

3 months ago

2.1.0

3 months ago

2.0.1

3 months ago

1.0.4

3 months ago

2.0.0

3 months ago

1.0.3

7 months ago

1.0.2

7 months ago

1.0.1

7 months ago

1.0.0

7 months ago