1.0.0 • Published 4 years ago

ordbok-mongodb v1.0.0

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

Orðbók MongoDB

Old Norse dictionary for Node.js. MongoDB implementation.

Uses Orðbók for dictionary data.

Install

yarn add ordbok-mongodb

Usage

Set up the database:

const { toMongoDB } = require('ordbok-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('ordbok-mongodb')

// Your MongoDB config.
const config = {...}

/**
 * Get collection & client instance.
 * You can also do it yourself without Orðbók.
 */
const { collection, client } = await getCollection(config)

// Any valid MongoDB query.
const wordsStartingWithS = await collection.find({ startsWith: 's' }).toArray()

console.log(wordsStartingWithS)

Schema for word entries:

{
    word: String,
    definition: String,
    type: String,
    gender: String,
    branch: String,
}

Sources

Scraped from word list compiled by Vikings of Bjornstad. The sources for the compiled list come from: