0.9.0 • Published 4 years ago
sanakirju-mongodb v0.9.0
Sanakirju MongoDB
MongoDB implementation of Sanakirju, a Karelian - Finnish dictionary with over 90 000 words. Based on data from Karjalan Kielen Sanakirja.
Install
yarn add sanakirju-mongodb
Usage
Set up the database:
const { toMongoDB } = require('sanakirju-mongodb')
// Your MongoDB config.
const config = {
url: '', // Your connection string.
dbName: 'yourDBName', // Created if new.
collectionName: 'yourCollectionName', // Created if new.
}
// Run only once to create & populate the database.
const res = await toMongoDB(config)
console.log(res)
Query the database:
const { getCollection } = require('sanakirju-mongodb')
// Your MongoDB config.
const config = {...}
/**
* Get collection & client instance.
* You can also do it yourself without Sanakirju.
*/
const { collection, client } = await getCollection(config)
// Any valid MongoDB query.
const wordsStartingWithU = await collection.find({ startsWith: 'u' }).toArray()
console.log(wordsStartingWithU)
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).
0.9.0
4 years ago