MCPcopy Create free account
hub / github.com/AlexErrant/Pentive / convert

Function convert

shared-dom/src/language/query2sql.ts:118–148  ·  view source on GitHub ↗
(input: string, now: Date)

Source from the content-addressed store, hash-verified

116}
117
118export function convert(input: string, now: Date) {
119 const tree = parser.parse(input)
120 const context = new Context(now)
121 tree.cursor().iterate(
122 (node) => astEnter(input, node, context),
123 (node) => {
124 astLeave(input, node, context)
125 },
126 )
127 serialize(context.root, context)
128 return {
129 sql:
130 context.sql.length === 0
131 ? null
132 : (sql.join(context.sql, sql``) as RawBuilder<SqlBool>),
133 joinCardTag: context.joinCardTag,
134 joinNoteTag: context.joinNoteTag,
135 cardTagCount: context.cardTagCount,
136 noteTagCount: context.noteTagCount,
137 joinCardTagFts: context.joinCardTagsFts,
138 joinNoteTagFts: context.joinNoteTagsFts,
139 joinNoteValueFts: context.joinNoteValueFts,
140 joinNoteFieldValue: context.joinNoteFieldValue,
141 joinCardSettingNameFts: context.joinCardSettingNameFts,
142 joinTemplateNameFts: context.joinTemplateNameFts,
143 joinLatestReview: context.joinLatestReview,
144 joinReview: context.joinReview,
145 joinFirstReview: context.joinFirstReview,
146 fieldValueHighlight: context.fieldValueHighlight,
147 }
148}
149
150// https://stackoverflow.com/a/28798479
151export function unique(str: string) {

Callers 2

CardsTableFunction · 0.90
study.data.tsFile · 0.90

Calls 4

astEnterFunction · 0.70
astLeaveFunction · 0.70
serializeFunction · 0.70
parseMethod · 0.45

Tested by

no test coverage detected