Howto set cell.setValue and avoid cellEdited callback? - tabulator

I'm trying to load additional data into tabulator using setValue,
but I do not want cellEdited would be called.
_cell.setValueActual(value);
Is everything what is required, but it's not 'public' function.
e.g.: restoreOldValue calls
_cell.setValueActual(value);
Maybe some specific function exists to set value for the cell directly
with out all additional callbacks and checks?

Related

get default value from Default Value control in Maximo autoscript

In a Maximo 7.6.0 automation script, I can get the default value from the Default Value in Database Configuration with a chain of calls like this:
mbo.getThisMboSet().getMboSetInfo().getMboValueInfo("WONUM").getDefaultValue()
If there is a textbox with inputmode="default", I can get that default value with a chain of calls like this:
mbo.getThisMboSet().getDefaultValue("WONUM")
If there is also a Default Value control in play, what is the chain of calls to get that default value? (The calls above still return the same things.)
It doesn't look like there is an easy way to get this data via some helper method like those. The setAppDefaultValue() method reads these values in and applies them to the MBO at some point during the load or init of the MBO.
According to the JavaDocs for that method (https://developer.ibm.com/static/site-id/155/maximodev/7609/maximocore/businessobjects/psdi/mbo/Mbo.html#setAppDefaultValue()), the data is stored in the appfielddefault table, if you wanted to pursue that route.
Looking through the code of that method, it fetches a few pieces of information and then uses the data dictionary to get all of that default data (via the following line).
/* 7320 */ HashMap defaultAppVal = getMboServer().getMaximoDD().getAppFieldDefaults(appStr.toUpperCase(), getMboSetInfo().getObjectName().toUpperCase(), siteStr, getUserName().toUpperCase(), groupSet);

Firebase multi-path update set a parent node to null

I am trying to use firebase realtime database multi path updates.
However trying to set a parent node to null as below will result on an error.
const firebaseUpdate = {}
firebaseUpdate[`user/${uid}`] = null
db.ref().update(firebaseUpdate)
Error: Reference.update failed: First argument contains a path /user/USER_ID
that is ancestor of another path /user/USER_ID/creationTime
I was wondering if there is a way to use multi-path updates in order to set a parent node with multiple children to null.
I assume I could use remove or set function but I'd rather use the multi-path update.
The error message indicates that you're trying to apply two conflicting updates to the database in one operation. As the message says, your update tries to:
write to /user/USER_ID
write to /user/USER_ID/creationTime
The second one write is a child of the first one. Since the order of writes in a multi-location is unspecified, it's impossible to say what the outcome of the write operation will be.
If you want to replace any data that currently exists at /user/USER_ID with the creationTime, you should update it like this:
db.ref().update({
"/user/USER_ID": { creationTime: Date.now() }
})

How can I check if there is a specific parameter in a sails.js request?

How can I check whether there is a specific parameter inside req.param() in sails.js?
For example, I want to check whether the parameter X_id exists in req.param(). If the parameter exists, then I want to use it. If it doesn't exist, then I want to use a default value instead. I've tried the following code:
X_owner: req.param('X_id') || -1,
But I receive an error when I run this code with out X_id parameter. How can I fix the code?
If you're aiming to use default values for your parameters, I'd suggest using actions2 if you haven't tried. It lets you define parameters (using the inputs' object) and use defaultsTo on inputs you want to have default values for, just like in your models attribute definitions. Using these should help resolve the issue.
As for how to check whether there is a specific parameter inside req.param(), you can use req.allParams() to reveal all current parameters from all sources. These include parameters parsed from the url path, the request body, and the query string in that order.

Array to function parameters

I'm using the node.js Redis library and I'm attempting to bulk-subscribe to many keys. I've got an array which is dynamic i.e
var keys {'key1','key2',...,'keyN'}
and I want to feed each index in as parameters to subscribe in the Redis library which takes one or more string(s). I've tried the apply function in JS using..
redisClient.subscribe.apply(this,keys);
but it doesn't cause a subscription. Any suggestions on how I can get over this issue?
Your example data is totally invalid JS, but I'm assuming you have it correct in your code.
You need to set the proper function context:
redisClient.subscribe.apply(redisClient, keys);

node-postgres: how to prepare a statement without executing the query?

I want to create a "prepared statement" in postgres using the node-postgres module. I want to create it without binding it to parameters because the binding will take place in a loop.
In the documentation i read :
query(object config, optional function callback) : Query
If _text_ and _name_ are provided within the config, the query will result in the creation of a prepared statement.
I tried
client.query({"name":"mystatement", "text":"select id from mytable where id=$1"});
but when I try passing only the text & name keys in the config object, I get an exception :
(translated) message is binding 0 parameters but the prepared statement expects 1
Is there something I am missing ? How do you create/prepare a statement without binding it to specific value in order to avoid re-preparing the statement in every step of a loop ?
I just found an answer on this issue by the author of node-postgres.
With node-postgres the first time you issue a named query it is
parsed, bound, and executed all at once. Every subsequent query issued
on the same connection with the same name will automatically skip the
"parse" step and only rebind and execute the already planned query.
Currently node-postgres does not support a way to create a named,
prepared query and not execute the query. This feature is supported
within libpq and the client/server protocol (used by the pure
javascript bindings), but I've not directly exposed it in the API. I
thought it would add complexity to the API without any real benefit.
Since named statements are bound to the client in which they are
created, if the client is disconnected and reconnected or a different
client is returned from the client pool, the named statement will no
longer work (it requires a re-parsing).
You can use pg-prepared for that:
var prep = require('pg-prepared')
// First prepare statement without binding parameters
var item = prep('select id from mytable where id=${id}')
// Then execute the query and bind parameters in loop
for (i in [1,2,3]) {
client.query(item({id: i}), function(err, result) {...})
}
Update: Reading your question again, here's what I believe you need to do. You need to pass a "value" array as well.
Just to clarify; where you would normally "prepare" your query, just prepare the object you pass to it, without the value array. Then where you would normally "execute" your query, set the value array in the object and pass it to the query. If it's the first time, the driver will do the actual prepare for you the first time around, and simple do binding and execution for the rest of the iteration.

Resources