RafaelGB / obsidian-db-folder

Obsidian Plugin to Allow Notion like database based on folders
MIT License
1.24k stars 61 forks source link

Unable to use Javascript, Database Disappears #851

Closed ccr112393 closed 1 year ago

ccr112393 commented 1 year ago

Hi!

I am experiencing a similar issue to the one below. I've enabled Javascript and specified my scripts folder, but DB Folder doesn't seem to be able to see the files and when I enable Javascript at the database level it completely disappears.

    Hey, I can’t use javascript in formula,

I have a code in "/js/test.js"

function test(){
    return "test";
}
module.exports = test;

I’m using the formula ${db.js.test()}

So my filename seems good, in setting, I activated the JS, and select the folder "js" What is the problem ?

Originally posted by @VociNur in https://github.com/RafaelGB/obsidian-db-folder/discussions/784

ccr112393 commented 1 year ago

Here's a quick screen recording showing what happens.

donovanrost commented 1 year ago

I'm having a very similar issue. DBFolder doesn't seem to recognize my .js files. To sort of test this, I set my formula to ${JSON.stringify(db.js)} and the value is {}.

ccr112393 commented 1 year ago

It started working for me. I can’t say for certain, but I think it was because I had an error in my code. But it would still happen even if I only had the example script in the folder. Not sure - but it has been working well for the last few days! Thank you dev for such an awesome plugin!

Pukimaa commented 1 year ago

Having the same issue with this code:

/**
 * Formula: ${db.js.punkte(row.hausaufgaben,row.gelernt)}
 * @param {*} hausaufgaben [idk the type of booleans so this type is empty]
 * @param {*} gelernt int
 * @returns string representing the status of the goal
 */
function punkte(hausaufgaben, gelernt) {
  var hausaufgaben_punkte = 0;
  if (hausaufgaben) {
    hausaufgaben_punkte = 3;
  }
  return gelernt / 10 + hausaufgaben_punkte;
}

module.exports = punkte;

It gives the following error (which seems to be an error of the error handling saying it couldnt run the formula): image

Pukimaa commented 1 year ago

@RafaelGB @ccr112393