Security News
npm Updates Search Experience with New Objective Sorting Options
npm has a revamped search experience with new, more transparent sorting options—Relevance, Downloads, Dependents, and Publish Date.
@qrvey/data-persistence
Advanced tools
![install size](https://packagephobia.com/badge?p=%40qrvey%2Fdata-persistence)
You can install the package using npm or yarn:
npm install @qrvey/data-persistence
Or with yarn:
yarn add @qrvey/data-persistence
This package has the following peer dependencies:
@aws-sdk/client-dynamodb
(v3.x) and @aws-sdk/lib-dynamodb
(v3.x) for interacting with DynamoDB.pg
(v8.x) and pg-format
(v1.x) for interacting with PostgreSQL databases.This class serves as the foundation for interacting with your database. It exposes methods for performing CRUD operations on entities (data objects).
create(entity: T)
: Creates a new entity in the database.findAll(options: IFindOptions)
: Retrieves all entities based on specified options, this function make an internal pagination to load all data.findItem (options: IFindOptions)
: Fetches a single entity by a specified filter.update(filters: IFilter[], data: Partial<T>)
: Updates entities matching the provided filters with the given data.remove(filters: IFilter[])
: Deletes entities that satisfy the specified filters.These methods assist in constructing filters, query indexes, and sorting criteria for use within your CRUD operations.
buildFilter(attribute: string, value: string, operator = 'EQUAL')
: Creates a filter object for a specific attribute.buildQueryIndex(indexName: string, columns: string[])
: Constructs a query index for efficient data retrieval.buildSort(column: string, direction: SortDirection)
: Generates a sorting object for ordering results.This interface defines the structure of a database table. It allows you to specify the table name, columns, and optional schema and pool usage.
static table: string | ITableName
: This property defines the name of the database table that the CrudService will interact with. It can be a simple string (e.g., "users") or an object implementing the ITableName interface (discussed later).
static columns: ITableColumns
: This property represents an array of column definitions for the table. It should conform to the ITableColumns interface (discussed later). Each column definition likely specifies details like column name, data type, and potentially constraints.
static usePool?: boolean = false
: This optional boolean property (defaulting to false) indicates whether to use a connection pool for database interactions. Setting it to true can improve performance for frequent queries.
static schema: string | null = null
: This optional string property allows specifying the schema name (if applicable) where the table resides. It can be a string (e.g., "public") or null if the default schema is used.
This library provides a set of filter operators for performing comparisons on entity attributes within your database. These operators allow you to construct filters for your CRUD operations.
The FilterOperator enum defines the following operators:
FAQs
![install size](https://packagephobia.com/badge?p=%40qrvey%2Fdata-persistence)
The npm package @qrvey/data-persistence receives a total of 2,087 weekly downloads. As such, @qrvey/data-persistence popularity was classified as popular.
We found that @qrvey/data-persistence demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
npm has a revamped search experience with new, more transparent sorting options—Relevance, Downloads, Dependents, and Publish Date.
Security News
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.