Exemple #1
0
        public object Select(HttpListenerContext ctx, string postdata, string db, string table, UInt64 key)
        {
            try
            {
                using (var lmdb = new Lightning(Path.Combine(dbpath, db), 1))
                {
                    var keybytes = BitConverter.GetBytes(key);
                    var value    = lmdb.Get(table, keybytes);
                    if (value == null)
                    {
                        return(GenerateSuccess($"Table contains no elements for key {key}"));
                    }
                    var valuestr = Encoding.UTF8.GetString(value);

                    return(GenerateSuccess(valuestr));
                }
            }
            catch (Exception ex)
            {
                log.Error(ex);

                return(GenerateError(ex.Message));
            }
        }