database

package
v0.0.0-...-d52e2b0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 5, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteDocuments

func DeleteDocuments(db *sqlx.DB, ids ...int) (err error)

DeleteDocuments remove documents in database.

func InsertDocuments

func InsertDocuments(db *sqlx.DB, docs ...Document) (err error)

InsertDocuments save the documents into the database.

func Open

func Open(path string) (db *sqlx.DB, err error)

Open SQLite database in specified path.

Types

type Document

type Document struct {
	ID      int    `db:"id"`
	Content string `db:"content"`
}

func FetchDocuments

func FetchDocuments(db *sqlx.DB, ids ...int) ([]Document, error)

FetchDocuments returns documents with specified IDs.

type TokenLocation

type TokenLocation struct {
	DocID int `db:"document_id"`
	Count int `db:"n"`
}

func SearchTokens

func SearchTokens(db *sqlx.DB, keys ...string) ([]TokenLocation, error)

SearchTokens look for document ids which contains the specified tokens, then count how many tokens occured in each document.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL