In order to write an app handling the database responses I need to know the possible structures and values of the ubiquitous error parameter.
all the callbacks have:
function(err, res) ...
Does anyone know about the structure of the err object?
When provided to the callback, the err parameter contains an Error-based object. The name property of the object can be used to differentiate the types of errors, and the message property contains a string description of the error.
Looks like $err is usually a string type. See http://jp.wiki.mongodb.org/display/DOCS/Error+Handling+in+Mongo+Drivers
Related
I'd like to be able to GET a value of a key and immediately know what type it is. I'm using
res, err := conn.Do("GET", key)
This returns an interface{} in res. Depending on the type, I'd like to call one of the helper functions like redigo.String(res) or redigo.Bool(res). I know I can do conn.Do("TYPE", key) to get the type separately, but how can I get the type just from the result of one GET request?
Wait, REDIS TYPE command does not provide you the details of value type it just tells you whether the key's value is a string, list, set, zset, hash, or stream.
So your application code or client code must identify what's it's equivalent for your programming language.
You can try to decode your data using the known key value types.
I need to be able to create an event processing rule that when you add a new device, you take a string value from one fragment (e.g.: c8y_Hardware.imei) and use that string to populate another fragment (e.g: c8y_Mobile.imei). So the new device would then have the same value in both c8y_Hardware.imei and c8y_Mobile.imei.
We have attempted setting up the appropriate CEP rules, but they are not working (they do compile and save).
insert into UpdateManagedObject
select
m.id as id,
{
"c8y_Mobile.imei", getString(m,"c8y_Hardware.imei")
} as fragments
from
ManagedObjectCreated as m
where
getString(m,"c8y_Hardware.imei") != "";
Any guidance on where we are messing up our syntax would be greatly appreciated.
It should be: m.managedObject.id as id.
Usually you would also get an error on compile but it can be that the streams also have an id so that it technically works in CEP. You should be able to check if it triggers on the debug stream and see the id that has been set.
Same applies for all other Cumulocity streams. The streams itself e.g. ManagedObjectCreated or AlarmUpdated etc. are not the objects directly. They have always a property like in this case managedObject or for AlarmUpdated it is alarm. This property is the actual payload.
The helper methods like getString are written in a way that you can pass either the payload or the full stream object so there it does not matter.
The documention for git_treebuilder_insert seems to imply that it doesn't care whether the object being inserted is valid:
No attempt is being made to ensure that the provided oid points to an existing git object in the object database, nor that the attributes make sense regarding the type of the pointed at object.
However, when actually using the library to create tree objects, if I try to write an entry with an invalid oid, this function returns failure. As reference, here's the code:
if (filemode != GIT_FILEMODE_COMMIT &&
!git_object__is_valid(bld->repo, id, otype_from_mode(filemode)))
return tree_error("Failed to insert entry; invalid object specified", filename);
What is the intended behavior, the code or the documentation?
The documentation is outdated; the code behaves as expected. The change to validate object pointers was made in order to:
Allow library users to make assumptions about the safety of their projects. It is generally an error to create something that dangles and points to an object that does not exist.
Improve consistency between creating references and creating objects. Now they both validate that the thing(s) they're pointing to exist, by default.
If you do not want this behavior, you can disable it, by calling:
git_libgit2_opts(GIT_OPT_ENABLE_STRICT_OBJECT_CREATION, 0);
I am trying to log the contents of an object to a text file. If I do a debug.print of the object itself in the immediate window, it prints all of the values of the object's properties:
?mDb.DatabaseOptions
{Microsoft.SqlServer.Management.Smo.DatabaseOptions}
AnsiNullDefault: False
...
UserData: Nothing
However, I can't seem to access this as a string in code due to a type mismatch. I assumed I could get this information using the .ToString method, but all that returns is the object description with none of the properties or values:
?mDb.DatabaseOptions.ToString
"Microsoft.SqlServer.Management.Smo.DatabaseOptions"
What am I missing?
.ToString is a function on the base object (see http://msdn.microsoft.com/en-us/library/system.object.tostring.aspx). Debug.Write is a function that can iterate though the properties writing the values.
As Stu said you can do this yourself using Reflection.
You could also add/change the trace listeners to write out the information else where.
Debug.Print enumerates all properties for you. Is that what you are looking for? If so, you will have to examine all properties through reflection.
The function shown below is a stub of a Service operation implemented in WCF Data Services, it accepts a string parameter and returns a string as well, how do I call this operation and read the returned string value back?, thank you.
[WebGet]
public string vMobile_FinishExport(string RouteCode);
I tried this
consumer.getEntities("vMobile_FinishExport?RouteCode='AA'").execute();
and it works without any problems, but I could'nt get through to read the returned string. The code samples I have gone through only shows reading entities and property values.
Thank you.
Use ODataConsumer#callFunction [1] to make a function call instead of getEntities.
Hope that helps,
- john
[1] http://odata4j.googlecode.com/hg-history/0.5/odata4j-core/doc/javadoc/org/odata4j/consumer/ODataConsumer.html#callFunction(java.lang.String)
Can you try below code , its working without any problem...
//printNameis the service operation method name
//"XYZ" is the passing parameter
OFunctionRequest<OObject> oFunctionRequest = oDataJerseyConsumer.callFunction("printName");
oFunctionRequest = oFunctionRequest.pString("printName", "XYZ");
Enumerable<OObject> s = oFunctionRequest.execute();
System.out.println(s.elementAt(0));