Can not add function to mongodb - mongodb

I don't know when the problem begin. I find that when i create a new function to mongodb, and then run it like this:
db.loadServerScripts();
testFun('xxx');
Two errors will occur:
SyntaxError: missing } after property list src/mongo/shell/db.js:1038
ReferenceError: testFun is not defined (shell):1
But the old functions work fine. And when I delete one old function, and recreate it without anything changed, it also results in the same error above.
The version of mongodb I used is 2.6.10.

I think I have found the answer to this question. The error was cased by some other function. The error message puzzled me , I used to think that it must be an error from the mongo itself. I delete some mongo function written by me, and then the error was missing. Now I can run testFun successfully.

Related

How can I resolve this syntax error in JPQL?

I am fairly new to JPQL and coming from SQL there are some things I still need to get familiar with, so the problem might be caused by that fact.
Working with the CUBA-Framework, I am trying to create a new entity with a JPQL like a form of projection in SQL and I already have succeeded in doing so but now with another case, I got a syntax error. So here is my JPQL:
SELECT NEW
com.example.vet.entity.vet_AnimalInformation(a.cage,0,0,'test',0)
FROM vet_Animals a
This gets transformed internally into what you can see in the exception below and gives me an error:
An exception occurred while creating a query in EntityManager:
Exception Description: Syntax error parsing
[SELECT NEWcom.example.vet.entity.vet_AnimalInformation(tempEntityAlias,0,0,'test',0) FROM vet_Cage tempEntityAlias, vet_Animals a where tempEntityAlias.id = a.cage.id].
[71, 72] The SELECT clause has 'NEWcom.example.vet.entity.vet_AnimalInformation' and '(tempEntityAlias, 0, 0, 'test', 0)' that are not separated by a comma.
Whyever this restructuring occurs, I can live with that, although in comparison to SQL I feel a lack of influence on the statement here :) somehow the constructor is not recognized as such.
What am I doing wrong here?
Thanks in advance!
edit:
Now I wrote my original SELECT clause in the exact way like it is shown in the error message, after it was automatically rewritten and it works! At least I get another error stating that the constructor with those types of parameters could not be found but at least it is recognized as a constructor.
My guess was then that maybe in rewriting the statement then space between NEW and the contructor gets lost but when I leave that out in my original statement I get a totally different error.

Calling a python function from MATLAB, generates an object with only some attribute

From MATLAB I am calling a Python function that creates and returns a Python object MyPyObj created by me with some attribute. The object is correctly returned however some attribute is missing and when I try to access them in MATLAB, a No appropriate method, property, or field error is returned. Does someone know why this happens?
Have you already tried this:
commandStr = 'python /Users/myName/pathToScript/sqr.py 2';
[status, commandOut] = system(commandStr);
if status==0
fprintf('squared result is %d\n',str2num(commandOut));
end
I managed to solve the problem following this post. Basically I needed to use
py.getattr(myPyObj, 'name_of_the_hidden_attribute')
However I am still not able to understand why myPyObj.name_of_the_hidden_attribute throws an error. I want to provide also this link in case my solution does not fix the problem for other users.

breeze mongo manager.saveChanges() error

I'm learning from breeze-zza-mongodb sample.
I get some problems when i try to use the saveChanges() function from breeze.
This is the error i get:
"TypeError: Cannot read property 'update' of null at... node_modules\breeze-mongodb\mongoSaveHandler.js : 229:20 at Array.forEach"
Any of you tried and got this error? I searched Google for a bit longer but i can't find this issue. And if i try to manager.getChanges() and put the changes in array, i get my entity with modified state.
The guys from breeze didn't covered this part and i'm completly blind in this. Thank you for your time guys.
I solved my problem. I included the modules in VS so i can debug and i noticed that breeze misnamed my collection name for some reason adding an s at the end.
Anyway.. for now i just removed that, and it works. I will dig deeper to see where and why is breeze adding an s at the end of my collection name because i want to treat the cause, not the effect. Thanks.

Using matlab code in Octave - Bayes Net Toolbox

I am trying to run Kevin Murphy's Bayes Net Toolbox in Octave and encountering some problems. It doesn't help that I'm a novice at Bayesian networks, Matlab and Octave.
This toolbox was originally written for Matlab. There is a large test file called test_BNT.m which runs through all the functionality in the toolbox. Most of the error messages relate to the difference between & and && in Matlab and Octave. This is easy to fix. However, I've now come across a new problem and I don't know what to do about it.
For instance, the qmr1.m script creates an instance of the pearl_inf_engine class, sets some of the member member variables and passes the instance of the class to another function. Later on, the member variables are accessed again in a different script (parallel_protocol.m). But when this happens, the following message appears:
error: invalid index for class
error: evaluating argument list element number 1
It seems that from one script to another, it has forgotten that the class has any member variables and gives the invalid index message when you try to access them.
Is this a common error with an easy solution? Is something wrong with the path or working directory? Maybe someone else has already converted the BNT to octave and knows what to do?
Edit
I was able to get past this error message. The trick was to read the installation instructions (haha) and run addpath(genpathKPM(<BNT base directory)). genpathKPM.m is a script includes in BNT which adds all the required directories to the path.
After doing this, run test_BNT.m and change & to && and | to || at each line where it gives a warning. This will clear up most of the errors.
However, I'm still unable to run mpe1.m, mp2.m, mildew1.m and some others. The new error message I'm stuck on is:
error: invalid empty index list
error: called from:
error: C:\FullBNT-1.0.7\bnt\BNT\inference\static\#var_elim_inf_engine\find_mpe
.m at line 63, column 5
on this line of code:
eval(['sCPT.T(', sargs, num2str(jj), ')=0;']);
If I can get all the scripts to work, I'll post an answer here with the steps I took to do it.
Edit 2
I was able to get past the problem in the previous edit. Replace
eval(['sCPT.T(', sargs, num2str(jj), ')=0;']);
with
eval(['sCPT.T(', sargs, sprintf('%d',jj), ')=0;']);
The next problem is identical. Just replace num2str in the same way.
This file was apparently contributed by a user of BNT, and not written by the original author. Using eval kind of a hack, I think. A better fix would be to just rewrite the code so it doesn't use eval at all.
There is one more error in draw_graph.m, which was apparently also an outside contribution to the project. I just commented out the call to that function since I'm not interested in drawing graphs right now. After doing this, and continuing to fix shortcircuit operators, all of the tests in test_BNT.m will run.
Still, I won't create an answer for this until I can get draw_graph.m to run, too.
As a significant amount of time has passed, and the answer to the core problem was provided in the question, I will post it here so it will not stay listed as unanswered:
tl;dr: Change a few operators, solve the remaining bugs specified below, and everything works except the drawing of graphs.
Edit
I was able to get past this error message. The trick was to read the
installation instructions (haha) and run addpath(genpathKPM(<BNT base
directory)). genpathKPM.m is a script includes in BNT which adds
all the required directories to the path.
After doing this, run test_BNT.m and change & to && and | to
|| at each line where it gives a warning. This will clear up most of
the errors.
However, I'm still unable to run mpe1.m, mp2.m, mildew1.m and
some others. The new error message I'm stuck on is:
error: invalid empty index list
error: called from:
error: C:\FullBNT-1.0.7\bnt\BNT\inference\static\#var_elim_inf_engine\find_mpe
.m at line 63, column 5
on this line of code:
eval(['sCPT.T(', sargs, num2str(jj), ')=0;']);
If I can get all the scripts to work, I'll post an answer here with
the steps I took to do it.
Edit 2
I was able to get past the problem in the previous edit. Replace
eval(['sCPT.T(', sargs, num2str(jj), ')=0;']); with
eval(['sCPT.T(', sargs, sprintf('%d',jj), ')=0;']);
The next problem is identical. Just replace num2str in the same way.
This file was apparently contributed by a user of BNT, and not written
by the original author. Using eval kind of a hack, I think. A better
fix would be to just rewrite the code so it doesn't use eval at all.
There is one more error in draw_graph.m, which was apparently also
an outside contribution to the project. I just commented out the call
to that function since I'm not interested in drawing graphs right now.
After doing this, and continuing to fix shortcircuit operators, all of
the tests in test_BNT.m will run.

find-system-path

I am trying to determine the location of .rackettrc on Windows using the following command:
(find-system-path 'init)
as specified in the Racket documentation. However, I keep getting the error message
expects argument of type <system-path-symbol>: given 'init.
Is this a bug in Racket or am I doing something wrong?
Ah. I realized I was looking at the old documentation.
find-system-path now works now as follows:
(find-system-path 'init-file)