I'm building a service parsing some json string to object. I did not get the full object so several of the properties withtin the object is null.
When using "Data operations" to parse the JSON from the example data null becomes type "any". Every other property with data is defined as types string, number and so on works.
But properties defined as 'any' is not usable in the following steps in my logic app.
Looks like there's a bug in our schema generator.
For input like
{
"foo": null
}
We should generate schema like
{
"foo": {}
}
Instead of
{
"foo": { "type": "any"}
}
We will be fixing this soon, in the meantime, remove "type": "any" should make the token show in in subsequent steps.
Try to use code view if you are developing in Visual studio. You will get used to expression building in json easier rather than using designer. Sooner designer will be getting better and better.
Related
I'm trying to sort some data returned by a query in GraphQl. I'm running a Meteor/React/Apollo/Graphql stack, and this line allows me to obtain all the data in my database in a resolver resolvers.js : return database.find({}) I would like to sort it server-side by the "name" field and according to the docs and everything else I've been able to find online so far, return database.find({}).sort({name:1}) should have cut it, but it's not actually returning anything and I can't seem to figure out why, nothing shows up in my console and no errors are being thrown, and hence I believe it's just null or empty.
In my Robo3T console I can run database.find({}).sort({name:1}) and I can see the data actually being sorted. According to the docs I thought it may have been due to the Node implementation, and so I tried sort([["name",1]]) but that did not work either, and I'm not quite sure how else to go about this.
If there is no way to do this - should I just rely on client-side sorting? It's not many entries, < 100, and I think I should just sort it in the database itself because I never need the unsorted data and it's likely not even going to change much.
I would like to ask this regardless though, even if just sorting it once in my database is enough for this specific situation, how would I otherwise go about sorting data in a resolver, because I would need to do this in other instances?
Thanks!
EDIT - This is what I have:
export default {
Query: {
test_query(obj, args, context) {
// Bottom line is output
console.log("test1");
console.log(Database.find({}).sort({name:1}));
// Bottom line is not output
console.log("test2");
return Database.find({});
},
}
EDIT2: My database is defined as Database = new Mongo.Collection("db_name")
I believe you are looking at the wrong documentation. If this is indeed meteor, then Database is presumably a meteor collection, not a raw mongo collection. The interface on meteor collections is slightly different. In your case, I think you want:
Database.find({}, {sort: {name: 1}}).fetch();
.find() returns a cursor:
http://mongodb.github.io/node-mongodb-native/3.6/api/Collection.html#find
This works for Meteor pubsub, but not for GraphQL/Apollo. Try .find().toArray():
http://mongodb.github.io/node-mongodb-native/3.6/api/Cursor.html#toArray
Context: I am making a multi-language page using the react-i18next module of ReactJS.
Issue: I cannot access the arrayed JSON content.
The translated content being stored in separate JSON files for each language, non-array content works fine and gets correctly displayed and translated, however, I can't seem to use the arrayed content on my React components, let alone access its content through console.log().
Below is an example of my translationEN.json file:
{
"name": "Test",
"occupations":["occupation1",
"Part-time occupation2",
"Language enthusiast"]
}
I am being able to refer to the non-array name using i18n.t("name").
However, attempting to access my arrayed occupations using i18n.t("occupations") results in the following console.log:
key 'occupations (en)' returned an object instead of string.
Using JSON.stringify() doesn't solve the issue, neither does console.log(i18n.t("occupations"), { returnObjects: true }) as suggested on i18next's documentation
Thanks in advance!
Problem solved.
The array values can be accessed as such: i18n.t("occupations.0") for occupation 1, i18n.t("occupations.1") for Part-time occupation 2 and i18n.t("occupations.2") for Language enthusiast.
I just need to loop it out to make it look cleaner.
I have the following model for a Firestore document:
{
name: "test",
isActive: true,
items: [
{
id: "123",
itemName: "testItem",
qty: 1
},
{
id: "555",
itemName: "anotherItem",
qty: 5
}]
}
Now that Firestore allows to work with nested arrays (via arrayRemove / arrayUnion), I am wondering whether this is possible also through AngularFire2.
Or the only way so far is to import Firebase and using it straight ahead?
Like:
this.firestore.collection(<collectionName>).doc(<docID>).update({
answers: firestore.FieldValue.arrayUnion(<AnswersObject>)
});
Moreover is such a model with nested array legit in FIrestore or should it rather be structured in a different way?
Unfortunately, AngularFire2 does NOT yet support this. You can verify this by checking out the source code.
Or, if you're lazy like me and don't feel like digging through trying to find it on GitHub... what I did to double check was to download the whole repo as a ZIP file, extract, and open folder in VS Code. Searching the whole folder for FieldValue or arrayUnion returns nothing - those words don't exist in the entirety of the source.
So for right now, you're correct about needing to stick with the default Firebase/Firestore package. And nested arrays are definitely a "legit" thing, but like everything else, when to use it depends on your situation - and I don't feel qualified or experienced enough to evaluate your situation and make a strong recommendation.
I struggled with this a while, it seems angular's documentation is always behind. I updated an item the array like this, the array is called accomodation and it is within the day object.
this.data.firestore.doc(`days/${accommodation.day}`)
.update({
accommodation: [
accommodation
]
});
I'm using Google's Structured Data Testing Tool to investigate why Google isn't finding any structured data on my page.
On first loading the URL (https://www.languagesunited.co.uk), I get an "Uncategorised Error":
JSON-LD Missing '}' or object member name.
Within the test tool source windows, I can making a small change to the page (add a space somewhere) and re-run the validation, and it validates (except for the url needing to be www.example.com for the tool to work).
I'd be grateful for any advice if anyone has had a similar problem.
After some experimenting with different options and getting different results with the test tool, the answer was very simple. There were some invalid whitespace characters in my structured data. Switching on the "show invisibles" option in my editor allowed me to replace these with spaces, and the data validated successfully.
Both are, most likely, bugs in the SDTT.
If you paste the markup (instead of letting it fetch the URL), the SDTT detects the structured data immediately (letting it fetch first and then editing something in the detected markup is the same idea). So there’s probably something wrong with their URL fetching.
For the issue with the example domain, see these questions:
Google structured data error: “All values provided for http://www.example.com/ must have the same domain.”
Google SDTT error: “All values provided for http://www.example.com/ must have the same domain.”
Schema.org and ContactPoint use with validation failure: “All values provided for http://www.example.com/ must have the same domain.” (on Webmasters SE)
I've just realized that Google Structured Data Validation Tool requires you (or us) to include context, In example:
'#context': 'https://schema.org',
(schema.org includes it in all their examples, i.e.:
Example encoded as JSON-LD in a HTML script tag.
<script type="application/ld+json">
{
"#context": "https://schema.org/",
"#type": "Person",
"name": "Christopher Froome",
"sponsor":
{
"#type": "Organization",
"name": "Sky",
"url": "http://www.skysports.com/"
}
}
</script>
If you do so you will start getting results again.
Hey I am trying to create some object into salesforce. I have:
SObject myobj = new SObject();
myobj.setType("MyType");
...
But I got:
exceptionMessage='sObject type 'string' is not supported. If you are attempting to use a custom object, be sure to append the '__c' after the entity name. Please reference your WSDL or the describe call for the appropriate names.'
I didn't just put a 'string' there.
Anyone please give some suggestions?
Thanks a lot.
You don't say what you're trying to do by assigning the type, but it looks like you cannot set the type of an sObject in this way. The "string" the error is complaining about is the string "MyType" that you are trying to use to set the type of the sObject.
If you look at the page that describes the methods for sObjects,
http://www.salesforce.com/us/developer/docs/apexcode/index_Left.htm#CSHID=apex_methods_system_sobject.htm|StartTopic=Content%2Fapex_methods_system_sobject.htm|SkinName=webhelp
you will see that there is no "setType" method, only a "getType" method.
Why do you want to do this ? do you have the type in a variable that you want to use to create an object ?
There is a setType() method when using the Partner API. Is this what you are doing?
In this case you just need to follow the exception message. All custom objects have a API name that end with "__c".
Try
myObj.setType("MyType__c");
The error you see can also happen in a completely different way. I found your question while trying to solve my problem with InvalidSObjectFault. In my case, it was not in how I specified the sObject's type. No. It was permissions. One user (Admin) could run the query but another (my API user) couldn't. Turns out the user's profile needs to have permissions set to see the object. If not then you get this fault message!
Posted more about this on my blog:
http://sforcehacks.blogspot.ca/2013/11/invalidsobjectfault-invalidtype.html