all repos — litestore @ 03a48496e6fb3fb0b1a1660a4018bba58255f6a3

A minimalist nosql document store.

types.nim

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
import db_sqlite 
from asynchttpserver import HttpCode 
from strtabs import StringTableRef, newStringTable

type 
  EDatastoreExists* = object of Exception
  EDatastoreDoesNotExist* = object of Exception
  EDatastoreUnavailable* = object of Exception
  EInvalidTag* = object of Exception
  EDirectoryNotFound* = object of Exception
  EInvalidRequest* = object of Exception
  Datastore* = object
    db*: TDbConn
    path*: string
  QueryOptions* = object
    select*: string
    single*:bool         
    limit*: int           
    orderby*: string      
    tags*: string
    search*: string
  TagExpression* = object
    tag*: string
    startswith*: bool
    endswith*: bool
    negated*: bool
  Operation* = enum opRun, opPack, opUnpack
  LiteStore* = object
    store*: Datastore
    address*: string
    port*: int
    operation*: Operation
    directory*: string
    file*: string
    appname*: string
    appversion*: string
  Response* = tuple[
    code: HttpCode,
    content: string,
    headers: StringTableRef]

const 
  CT_JSON* = {"Content-Type": "application/json"}

proc ctHeader*(ct: string): StringTableRef =
  return {"Content-Type": ct}.newStringTable

proc ctJsonHeader*(): StringTableRef =
  return CT_JSON.newStringTable

proc newQueryOptions*(): QueryOptions =
  return QueryOptions(select: "*", single: false, limit: 0, orderby: "", tags: "", search: "")