Details
-
Bug
-
Status: Open
-
Minor
-
Resolution: Unresolved
-
None
-
None
-
None
-
Debian 9, stretch
"apache-ignite-client": "^1.0.0"
-
Docs Required
Description
I am trying to navigate the Node.js client and discovered this oddity. I'm not sure what the design goal of the type system in the JS client is - is the goal to define some sort of default object, or is to define a schema? The object does not serve as a default object in my tests, so I'm wondering why I'm supposed to feed in actual values and not a schema, like with Mongoose. Nested complex types are also not consistently deserialized:
// Desired behavior: specify nested ComplexObjectType directly as a member, get deserialized nested object back const nest = new ComplexObjectType({ num: 0 }); const ty = new ComplexObjectType({ foo: "", nest }); // Uncommenting the following line results in the expected value being returned: // ty.setFieldType("nest", nest); const cache = (await igniteClient.getOrCreateCache("myCache")) .setKeyType(ObjectType.PRIMITIVE_TYPE.INTEGER) .setValueType(ty); await cache.put(1, { foo: "bar", nest: { num: 1 } }); // Expected output: // { foo: "bar", // nest: { // num: 1 } } // // Actual output: // { foo: "bar", // nest: BinaryObject } console.dir(await cache.get(1)); // Additionally, not defining 'nest' in the ComplexObjectType and defining it later will throw: const nest = new ComplexObjectType({ num: 0 }); const ty = new ComplexObjectType({ foo: "" }); ty.setFieldType("nest", nest); // -> IgniteClientError: Field "nest" is absent in the complex object type
Honestly, working with the JS library without types is hugely painful, even with the JS doc. If I am encouraged, I would happily move the Node.js client over to Typescript.
Tom
p.s. This is my first issue on JIRA. If it's not filed in the correct place or doesn't take the right format - sorry