npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

iralib

v1.0.6

Published

the tool for executing sql queries using bodiless func approach

Downloads

37

Readme

Ira Framework

Hi, it is our first open source library. If you have any comments or objections, please report issues or left recommendations. Yes, this framework is similar to Spring Data :)

The goal of framework is to provide a convenient framework to fetch data from a database. To make it possible framework obligates:

  • Keep persistence classes small and readable
  • Get rid of code duplication
  • Use decorators as a imperative logic description

The library is available on https://www.npmjs.com/package/iralib

npm i iralib

API

First at all, you need to create a repository class and declare it as @Persistent(). The class will be added to persistence context.

To declare a method that executes query have to use the @NativeQuery() decorator. The decorator consumes native SQL query.

@Persistent()
class UserRepository<T> {

    @NativeQuery("SELECT * FROM table LIMIT 20")
    getInfoFromTable(): Promise<T> {
        return new Promise(() => {})
    }

}

Another way to use a native query is to use @NamedQuery(). To make it possible, you should create .yaml file with the mapping name => query:

GET_INFO_FROM_TABLE:
  SELECT * FROM public.t_faq LIMIT 20
@Persistent('./queries/sqls.yaml')
class UserRepository<T> {

    @NamedQuery("GET_INFO_FROM_TABLE")
    getInfoFromTable(): Promise<T> {
        return new Promise(() => {})
    }

}

Parameters

There are two ways how you can pass parameters to both @NamedQuery() and @NativeQuery():

  • Use ? as parameter
  • Use object with named parameters
Question params:

Question marks are use as placeholders for arguments. The ? are replaced on function's arguments order. If you pass a redundant argument to the function it will be ignored. If you miss one, it will be thrown an exception. Type check lies to developer's responsibility.

@NativeQuery("SELECT * FROM public.t_faq WHERE id = ? AND lang = ?")
findByIdAndLang(id: number, lang: string): Promise<T>  {
    return new Promise(() => {})
}
Named params:

If you pass only argument of NamedArguments instance, framework recognizes it as named params. The named params look for naming match. It replaces all named params to arguments. If you add a redundant param to object argument it will be ignored. If you miss one, it will be thrown an exception. Type check lies to developer's responsibility.

@NativeQuery("SELECT * FROM public.t_faq WHERE id = ?id AND lang = ?lang AND lang LIKE ?lang")
findByIdAndLang(params: NamedArguments): Promise<T>  {
    return new Promise(() => {})
}

Running queries

  1. Create a persistent class

    @Persistent()
    class UserRepository<T> {
       
        @NativeQuery("SELECT * FROM table LIMIT 20")
        getInfoFromTable(): Promise<T> {
            return new Promise(() => {})
        }
       
    }
  2. Create a database connector. OOTB connectors are MySQL and PostgreSQL. PostgreSQL connector consumes pool configuration of pg package MySQL connector consumes pool configuration of mysql2 package.

    const postgreConnector = new PostgreSQLConnector(POSTGRESQL_DB_POOL_CONNECTION_CONFIGURATION);
  3. Create an instance of your repository:

    const userRepository = PersistentExecutor(new UserRepository(), postgreConnector);
  4. Look the result :)

    userRepository.getInfoFromTable().then((resp: any) => console.log(resp));
If there is a need to create an own connector, you can use IraPersistentConnector interface to
come up with a connection logic and a transaction handling. 

Typed result set

The framework supports type binding. If we use a typescript, possibly you want to fetch data as a class. It is possible by defining a required model. Notice, such class has to have _variable field notation. Apparently, we consider such variables as private, for this point it is better to make them public and initialized. Otherwise, variables won't be visible. Any methods can be declared to obtain the result. We agree it is not the best way to bind result to structure, but such idea occurred to us as an extra non-main feature.

class UserModel implements Model {
    public _id: number = 0;
    public _lang: string = '';

    getId(): number {
        return this._id;
    }

    getLang(): string {
        return this._lang;
    }
}
const userRepository = PersistentExecutor(new UserRepository<UserModel>(), client, UserModel);
userRepository.findByIdAndLang(new NamedArguments({
    lang: 'en',
    id: 2
})).then((resp: UserModel) => resp instanceof UserModel ); // => true