not found should return null

This commit is contained in:
sawka 2024-06-03 13:43:50 -07:00
parent f148d7fcf2
commit f90554e87e
3 changed files with 8 additions and 2 deletions

View File

@ -20,7 +20,7 @@ console.log("Wave Starting");
document.addEventListener("DOMContentLoaded", async () => { document.addEventListener("DOMContentLoaded", async () => {
console.log("DOMContentLoaded"); console.log("DOMContentLoaded");
// ensures client/window are loaded into the cache before rendering // ensures client/window/workspace are loaded into the cache before rendering
await WOS.loadAndPinWaveObject<Client>(WOS.makeORef("client", clientId)); await WOS.loadAndPinWaveObject<Client>(WOS.makeORef("client", clientId));
const waveWindow = await WOS.loadAndPinWaveObject<WaveWindow>(WOS.makeORef("window", windowId)); const waveWindow = await WOS.loadAndPinWaveObject<WaveWindow>(WOS.makeORef("window", windowId));
await WOS.loadAndPinWaveObject<Workspace>(WOS.makeORef("workspace", waveWindow.workspaceid)); await WOS.loadAndPinWaveObject<Workspace>(WOS.makeORef("workspace", waveWindow.workspaceid));

View File

@ -156,6 +156,9 @@ func SetMeta(waveObj WaveObj, meta map[string]any) {
} }
func ToJsonMap(w WaveObj) (map[string]any, error) { func ToJsonMap(w WaveObj) (map[string]any, error) {
if w == nil {
return nil, nil
}
m := make(map[string]any) m := make(map[string]any)
dconfig := &mapstructure.DecoderConfig{ dconfig := &mapstructure.DecoderConfig{
Result: &m, Result: &m,

View File

@ -103,7 +103,10 @@ func DBGetORef(ctx context.Context, oref waveobj.ORef) (waveobj.WaveObj, error)
table := tableNameFromOType(oref.OType) table := tableNameFromOType(oref.OType)
query := fmt.Sprintf("SELECT oid, version, data FROM %s WHERE oid = ?", table) query := fmt.Sprintf("SELECT oid, version, data FROM %s WHERE oid = ?", table)
var row idDataType var row idDataType
tx.Get(&row, query, oref.OID) found := tx.Get(&row, query, oref.OID)
if !found {
return nil, nil
}
rtn, err := waveobj.FromJson(row.Data) rtn, err := waveobj.FromJson(row.Data)
if err != nil { if err != nil {
return rtn, err return rtn, err