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 🙏

© 2024 – Pkg Stats / Ryan Hefner

dbsearch

v1.1.0

Published

Generates a mysql query which will search keywords against text and numeric columns from one or multiple databases.

Downloads

5

Readme

DBSEARCH

Recherche dans une ou plusieurs bases de données pour des mots-clés de type fulltext ou integer.

Installation

npm install dbsearch

Usage

  • dbsearch.generate_query(q, table)
    • Génère un requête SQL, mais ne l'exécute pas
    console.log(dbsearch.generate_query(q,table));
  • dbsearch.execute_query(q, table, sql, function)
    • Génère et exécute la requête contre le serveur
    dbsearch.execute_query(q,table,sql, function(err, data) {
        if (err){console.log(err);}
        console.log(data)
    });
var q = "dor mar 214"; // Tous les keywords qui doivent être cherchés dans les tables. Si plusieurs mots sont présents dans q, alors chaque mot doit ête trouvé dans la table afin de retourner un résultat.
var table = [
    {
        type: "pharmacien", //Sera retourné dans la première colonne du résultat, utile lorsque la recherche est effectuée dans plusieurs tables.
        table: "prod_pharmacien.pharmacien", //chemin complet de la table à rechercher (db.table)
        colonne_text: ["prod_pharmacien.pharmacien.nom", "prod_pharmacien.pharmacien.prenom"], //chemin complet de toutes les colonnes de type texte (varchar, string, text...) à rechercher. !!! Toutes ces colonnes doivent posséder un index de type FULLTEXT
        colonne_numeric: ["prod_pharmacien.pharmacien.licence"], // chemin complet de toutes les colonnes de type numeric (integer, smallinteger, ...) à rechercher. Ces colonnes devraient avoir un index de type unique ou index
        colonne_a_retourner: ["prod_pharmacien.pharmacien.nom", "prod_pharmacien.pharmacien.prenom", "prod_pharmacien.pharmacien.licence", "prod_pharmacien.pharmacien.statut"], //chemin complet des colonnes à retourner
        join: [] //requete MYSQL pour faire le JOIN avec d'autres tables
    },
    {
        type: "pharmacie",
        table: "prod_pharmacies.pharmacies",
        colonne_text: ["nom", "adresse_ligne_1", "municipalite"],
        colonne_numeric: ["phone","fax"],
        colonne_a_retourner: ["nom", "adresse_ligne_1", "municipalite"],
        join: []
    }
];
var sql  = {
  host     : '',
  user     : '',
  password : ''
};

Voir demo.js

Logique complète

Si abc def && colonne_text
abc AND def AGAINST colonne_text

Si abc def 123 456 && colonne_text
abc AND def AND 123 AND 456 AGAINST colonne_text

Si 123 456 && colonne_text
123 AND 456 AGAINST colonne_text



Si abc def && colonne_numeric
NULL

Si 123 456 && colonne_numeric
123 AND 456 LIKE colonne_numeric

Si 123 456 abc def & colonne_numeric
123 AND 456 LIKE colonne_numeric



Si abc def && colonne_text && colonne_numeric
abc AND def AGAINST colonne_text

Si 123 456 && colonne_text && colonne_numeric
123 LIKE numeric OR 123 AGAINST text
AND
456 LIKE numeric OR 456 AGAINST text

Si abc def 123 456 && colonne_text && colonne_numeric
abc AND def AGAINST colonne_text
AND
123 LIKE numeric OR 123 AGAINST text
AND
456 LIKE numeric OR 456 AGAINST text

Logique simplifiée

Si seulement colonne_text && q
		foreach q, match() AND match()

Si seulement colonne numeric && q_text
		NULL
Si seulement colonne numeric && q_numeric
		foreach q, like() AND like()

Si colonne text && colonne_numeric && seulement q_text
		foreach q, match() AND match()
Si colonne text && colonne_numeric && seulement q_numeric
		foreach q, like_or_match() AND like_or_match()
Si colonne text && colonne_numeric && q_numeric && q_text
		foreach q_text, match() AND match()
		AND
		foreach q_numeric, like_or_match() AND like_or_match()