2020-08-28 07:34:50 +03:00
|
|
|
import * as Serializers from "~/node_common/serializers";
|
2020-08-28 01:05:20 +03:00
|
|
|
|
|
|
|
import { runQuery } from "~/node_common/data/utilities";
|
|
|
|
|
|
|
|
export default async () => {
|
|
|
|
return await runQuery({
|
|
|
|
label: "GET_EVERY_SLATE",
|
|
|
|
queryFn: async (DB) => {
|
|
|
|
const r = await DB.select("id", "slatename", "data").from("slates");
|
|
|
|
|
|
|
|
if (!r || r.error) {
|
|
|
|
return [];
|
|
|
|
}
|
|
|
|
|
|
|
|
const sanitized = r
|
|
|
|
.filter((each) => each.data.public)
|
|
|
|
.map((each) => Serializers.slate(each));
|
|
|
|
return JSON.parse(JSON.stringify(sanitized));
|
|
|
|
},
|
|
|
|
errorFn: async (e) => {
|
2020-09-01 02:47:53 +03:00
|
|
|
console.log({
|
2020-09-13 01:08:36 +03:00
|
|
|
error: true,
|
|
|
|
decorator: "GET_EVERY_SLATE",
|
2020-09-01 02:47:53 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
return [];
|
2020-08-28 01:05:20 +03:00
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|