foxql / database

Javascript object based database system.

Home Page:https://foxql.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

foxql-index

Inverted index database system simple implementation for foxql. Search result use case p2p connection proof.

Documentation

Install npm

npm i @foxql/foxql-index

Basic usage

const foxqlIndex = require('@foxql/foxql-index');

const database = new foxqlIndex();

database.pushCollection({
    collectionName : 'entrys',
    fields : [
        'title',
        'content'
    ],
    ref : 'documentId',
    schema : {
        title : {
            type : 'string',
            min : 3,
            max : 80
        },
        content : {
            type : 'string',
            min : 7,
            max : 500,
        },
        documentId : {
            makeFrom : ['title', 'content']
        }   
    }
});

Add Analyzer methods

database.useCollection('entrys').registerAnalyzer('tokenizer', (string)=>{
    return string.toLowerCase().replace(/  +/g, ' ').trim();
}); 

Add document

database.useCollection('entrys').addDoc({
    title : 'test title',
    content : 'test example content, very simple usage',
    documentId : 1
});

Search document

const results = database.useCollection('entrys').search("test query");
console.log(results);

Export Database

const dump = database.export();

Import Database

const dump = database.export();
database.import(dump);

Change analyzer methods sort

database.useCollection('entrys').registerAnalyzer('tokenizer', (string)=>{
    return string.toLowerCase().replace(/  +/g, ' ');
}); 
database.useCollection('entrys').registerAnalyzer('tokenizer2', (string)=>{
    return string.trim();
}); 

//if want aboving change methods sort

database.useCollection('entrys').analyzerSteps = [
    'tokenizer2',
    'tokenizer'
];
    

Delete document

database.useCollection('entrys').deleteDoc('ref id');

Get document by ref

database.useCollection('entrys').getDoc('ref id');

About

Javascript object based database system.

https://foxql.com

License:MIT License


Languages

Language:JavaScript 98.9%Language:HTML 1.1%