MCPcopy Create free account
hub / github.com/ShaanCoding/makeread.me / initTemplates

Function initTemplates

backend/src/db.ts:24–49  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

22}
23
24const initTemplates = async () => {
25 try {
26 const templates = createTemplateObjects()
27 if (!templates) {
28 throw Error('Failed to read template data')
29 }
30 // TODO: This will cause horizontal scaling issues. We should use a unique index on the folder field instead.
31
32 await FullTemplateModel.collection.drop().catch((err) => {})
33 await FullTemplateModel.create(templates)
34 } catch (error) {
35 console.error('Error adding templates:', error)
36 }
37
38 try {
39 const macros = createMacroObjects();
40 if (!macros) {
41 throw Error('Failed to read macros data')
42 }
43 // TODO: This will cause horizontal scaling issues. We should use a unique index on the folder field instead.
44 await MacroModel.collection.drop().catch((err) => {})
45 await MacroModel.create(macros)
46 } catch (error) {
47 console.error('Error adding macros:', error)
48 }
49}
50
51export const initMongoDB = async () => {
52 try {

Callers 1

initMongoDBFunction · 0.85

Calls 3

createTemplateObjectsFunction · 0.90
createMacroObjectsFunction · 0.90
catchMethod · 0.80

Tested by

no test coverage detected