'use strict';
import { and, eq } from 'drizzle-orm';
import { singleOrUndefined } from '../../../fd-toolbox/server/collections/single-funcs.js';
import { resourceNames } from '../../../fd-toolbox/resources/resource-names.js';
import { getQuery } from '../../meta/server/web/drizzle.js';
import { applyFilterToQuery, getTableColumn, runQuery } from '../../db/drizzle-queries.js';
import { createResource } from '../../meta/server/resources/crud-resources.js';
import { getDbSchema } from '../../db/db-schema.js';
import { schemaNames, columnNames } from '../../db/constants/schema-names.js';

var __defProp=Object['defineProperty'],__name=(_0x46edb8,_0x4ec388)=>__defProp(_0x46edb8,'name',{'value':_0x4ec388,'configurable':!![]});async function tryGetItemByItemName(_0x20a7b7,_0xdcd920){const _0x3c4ba6=getDbSchema(),_0x542314=_0x3c4ba6[schemaNames['itemSchema']],{query:_0x17ee60}=await getQuery(_0x542314);applyFilterToQuery(_0x17ee60,and(eq(getTableColumn(_0x542314,columnNames['userId']),_0x20a7b7),eq(getTableColumn(_0x542314,columnNames['name']),_0xdcd920)));const _0x2d80aa=await runQuery(_0x17ee60);return singleOrUndefined(_0x2d80aa);}__name(tryGetItemByItemName,'tryGetItemByItemName');async function getItemsByUserId(_0x173084){const _0x77d3da=getDbSchema(),_0x2b735e=_0x77d3da[schemaNames['itemSchema']],{query:_0x1cd10e}=await getQuery(_0x2b735e);return applyFilterToQuery(_0x1cd10e,eq(getTableColumn(_0x2b735e,columnNames['userId']),_0x173084)),runQuery(_0x1cd10e);}__name(getItemsByUserId,'getItemsByUserId');async function createItem(_0x2b4777){return createResource(_0x2b4777,resourceNames['item']);}__name(createItem,'createItem');

export { createItem, getItemsByUserId, tryGetItemByItemName };
