Skip to content

[Proposal] Include simplified api #350

Open
@alpha0010

Description

@alpha0010

For common procedures (e.g. basic selects/inserts), the complexity of the current api can feel excessive. I propose we include an alternate api for simple use cases.

To use, get a Database instance:

import sqlite from 'react-native-sqlite-storage/simple';
const db = await sqlite.open('bar.sqlite');

Then make calls on it:

class Database {
  /**
   * Get all results from the query.
   */
  async all<T> (sql: string, params?: DataType[]): Promise<T[]>;

  /**
   * Close the database.
   */
  async close (): Promise<void>;

  /**
   * Execute a statement.
   */
  async exec (sql: string, params?: DataType[]): Promise<void>;

  /**
   * Get the first result from the query.
   */
  async get<T> (sql: string, params?: DataType[]): Promise<?T>;
}

Thoughts? Suggestions?


See #336 for a potential implementation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions