Skip to content
This repository has been archived by the owner on Feb 18, 2023. It is now read-only.
/ sanakirju-knex Public archive

Knex.js / SQL implementation of Sanakirju dictionary.

License

Notifications You must be signed in to change notification settings

stscoundrel/sanakirju-knex

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sanakirju Knex.js

Knex.js / SQL implementation of Sanakirju, a Karelian - Finnish dictionary with over 90 000 words. Based on data from Karjalan Kielen Sanakirja. Example implementation for all Knex supported SQL databases, like PostgreSQL, MySQL, MariaDB or SQLite.

Install

yarn add sanakirju-knex

You also need to install the database driver you're going to use.

npm install pg
npm install sqlite3
npm install mysql
npm install mysql2

Usage

The library provides a way to create & populate a database based on your Knex config.

const { createDB } = require('sanakirju-knex')

/**
 * Your Knex config file. 
 * NOTE: Leave "migrations" empty.
 */
const knexConf = {...}

const res = await createDB(knexConf)
console.log(res)

To query the database, just use Knex as you always would.

const Knex = require('knex')

const knexConf = {...}
const knex = Knex(knexConf)

const aWords = await knex('words')
    .where({ startsWith: 'a' })

Sources.

Words & translations are from Karjalan Kielen Sanakirja created by Institute for the Languages of Finland. The original material is licenced under Creative Commons International (CC BY 4.0).