-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feedback from Insert Method #71
Comments
Thank you for your suggestion!
In your case example, if the model is valid, the result should return It was a design choice not to raise an error during call to runtime APIs. The goal was to avoid script break and to have all the informations about errors in the log. What I can do is to add some logs inside
By the way, you can add this line in your current script to have more information about the model generation. |
Thanks for a quick reply. I think it is a good idea not to raise an error during call to runtime APIs. However, it should be a feedback with some information. Therefore it would be great to see some documentation about debug log levels. Right now runtime.require('logger').level('debug') returns undefinded. As for insert method, it returns Array(0) [], whether an element was added or not. When I check my model, for example, I see an element was inserted, however the return value is an empty array. Exactly like the case, when an element was not added for this or that reason. |
I will have a look on
|
I have updated the library in order to fix an issue I have found with the I have also update the online documentation. |
Thanks for extending the documentation! I would add the case, with creation of references. It is clear how it is done, while creating components. However, it seems like it is not functioning the same way after a model was loaded: // add reference BTW insert was functioning properly. I was confused by documentation. I thought I have to create an instance firstly and then call the insert method. Therefore insert returned nothing back. |
You're welcome! And I will try to make the documentation clearer. About the creation of references, you mean like in this example ? What differences have you between adding a reference in the object like: new Jedi({
'_id': 'luke',
'firstName': 'Luke',
'lastName': 'Skywalker',
'father': 'anakin'
}); and by code like this: const anakin = this.require('anakin');
luke.father(anakin); |
Yes, this example is not functioning in my case for different types of models. I get the same error type each time. Here, how the error will look like for this example: runtime: invalid value for property 'father' on component 'a7aaad61-f679-41a5-a61a-e0c94d63eb08' (class '<anakin>'): expected type 'number' instead of type '<luke>' |
Can you give me a sample of the code that gives you that error ? So that I can fix the issue. |
I think mixed up collections with links. So I tried to add an element to a collection with the method ment for adding links. luke.father(anakin) -> add a link or reference |
Hi, I try this scripts (taken from the documentation), and it seems to work: const system = runtime.system('example10');
const metamodel = runtime.require('metamodel');
metamodel.schema('Jedi', {
'firstName': 'property',
'lastName': 'property',
'children': 'collection'
});
metamodel.create();
const Jedi = runtime.require('Jedi');
new Jedi({
'_id': 'leia',
'firstName': 'Leia Amidala',
'lastName': 'Skywalker'
});
new Jedi({
'_id': 'luke',
'firstName': 'Luke',
'lastName': 'Skywalker'
});
new Jedi({
'_id': 'padme',
'firstName': 'Padme',
'lastName': 'Amidala',
'children': ['luke', 'leia']
});
system.on('start', () => {
const padme = this.require('padme');
const luke = this.require('luke');
padme.children([luke]);
console.log(padme.children(0).firstName());
});
system.start(); Maybe something is different in your script. |
In comparison to the other methods, e.g. update, insert does not deliver any result:
result = runtime.require('db').collections().Person.insert({
'_id': 'luke',
'firstName': 'Luke',
'lastName': 'Skywalker'
});
Here, result is always Array(0) [], whether an element was added or not. The only hint is a message:
runtime: unknown property 'XXX' for the definition of 'Person'
runtime: invalid document ....
Which I cannot catch (any hint how I can do it will be appreciated), since it is not an error.
Would it be possible to update the method, so it returns, e.g.
The text was updated successfully, but these errors were encountered: