MongoDB Compass throws error: Update not permitted - mongodb

I am taking online class by MongoDB uni. and using a test free tier cluster. I have created a very simple collection with basic fields. Creation was successful. 5 documents. Each document has basic 8 fields as can be seen in the screenshot. The problem I am facing is I am getting error while inserting a new field called 'Number of Children(0-12 yrs)' with data type int32. This error occurring when I user data type as in32, int64, decimal128, double so far. It does not show up for string and a few other types. Being a beginner, I am not able to find more info on this error, please help.enter image description here

That looks like a bug. You can work around by entering your value as the string value and then converting it to the appropriate type.
I have filed a ticket with the Compass team. See https://jira.mongodb.org/browse/COMPASS-4300

Related

UUID type error when using NSBatchInsertRequest

I'm using NSBatchInsertRequest to save an array of data to Core Data and the model has an attribute id which is of type UUID. when I attempt to execute the batch insert I get id is not valid error, however when I change the type of id to String everything works fine.
It might worth mentioning that, when I try to save the array one by one without using NSBatchInsertRequest, id being UUID is not an issue.
I was wondering whether it's a known issue or I'm missing something?
Appreciate any guidance!
Edit I:
As mentioned in the comment section NSBatchInsertRequest works directly with SQlite and according to this question it is better to save UUID as String

how to filter Collection (Firebase) by uid in swift

I'm having problems trying to get one specific value from Firebase.
I'm using .whereField('uid', isEqualsTo: "givenID") in Collection("something") but I'm not getting any response. I know in Flutter the field is 'uid' but for some reason in swift isn't the same. I'll appreciate your help maybe with the name of the field or another way to bring the value with the given id in Firebase.
Useful information
Swift 5
XCODE 11.4.1
I found a "solution". Create a field in my Collection called "id" and assigning it with the same id from the document. Now I can just
db.collection("yourCollection").whereField("id", isEqualsTo: "givenID").
Not the best solution, but a solution is a solution.
UPDATE
I found it.
db.Collection("yourCollection").document("GivenID")
This bright you the subCollection
And that's all

Salesforce API - Using Compound fields. (Cannot deserialize instance of MailingAddress from VALUE_STRING)

Using REST API for Salesforce, I am trying to insert/update a contact into my business org where 'MailingAddress' is one of the fields with some set data, though in response I am getting this error message 'Cannot deserialize instance of MailingAddress from VALUE_STRING', the same response also resulting in 'OtherAddress'.
To my understanding, I think this is due to the reason that 'MailingAddress' and 'OtherAddress' are not actual fields that contains some String data, rather they take a dynamic address which resulting in filling up all other related fields like - 'MailingCity, MailingStreet, etc'.
So I have 2 questions:
1. How can I set 'MailingAddress' and 'OtherAddress' fields using API parameter only?
2. Is there any manual/documentation for this reference? As I am also having trouble with 'OtherLatitude' and 'OtherLogitude' fields.
Address and geolocation fields are compound fields.
You need to provide the value for the different components of the field, so for example, for MailingAddress you would need to provide MailingStreet, MailingCity, MailingState or MailingStateCode, etc. And for OtherAddress you would provide OtherStreet, OtherCity, etc.
For more information on compound fields: https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/compound_fields.htm

Clio API - What is the correct format to Update (PATCH) a custom field value for a matter

Anyone been able to successfully update the custom_field_values for a matter via Clio's API?
I'm trying to update the value for custom_field_values under a single matter. I'm able to send a JSON string using PATCH and update the default values for a matter like location or description using the following format
{"data":{"location":"Orange"}}
But when it comes to updating a "custom field value" I'm getting a 422 Unprocessable Entity error. I'm following Clio's v4 API Documentation and my understanding is that to update a custom_field_value you need the following JSON:
{"data":{"custom_field_values":[{"id":658213,"custom_field":{"id":139385},"value":"New Value Goes Here!"}]}}
However here is the message coming with the 422 error:
{"error":{"type":"ArgumentError","message":"An invalid argument was supplied: invalid custom field value id provided, acceptable format is <type>-<unique id>"}}
I can't interpret the part suggesting the acceptable format!
I've also tried sending the JSON in the following format which is closest to Clio's V2 API Docs for updating a custom field:
{"data":{"custom_field_values":[{"custom_field":{"id":139385},"value":"New value goes here"}]}}
But then this is what I get back:
{"error":{"type":"ArgumentError","message":"An invalid argument was supplied: custom field value for custom field 139385 already exists"}}
Please note that this is being tested in POSTMAN regardless of my development environment. I appreciate your response!
I've successfully created queries to update custom field values in matters many times, and these run all the time for me. I've compared your json to some examples of the json I'm successfully sending. Your syntax appears correct, but there's enough missing for me to only guess at where your mistake might be.
First, you're sending a PATCH to https://app.clio.com/api/v4/matters/{matter id}.json right? It took me a while to learn that you can't update the value of a matter's custom field with a query to https://app.clio.com/api/v4/custom_fields/{id}.json.
Second, just to clarify, the 658213 id you used above (the first id field) should be the unique id of this instance of your custom field. You won't get this until you've created an instance of the custom field particular to this matter. The second id field, where you've put 139385 is the id for the custom field itself, which you could get with a query to https://app.clio.com/api/v4/custom_fields.json.
If you're looking in the V.4 docs under Custom Fields, you won't find this, or at least I didn't. BUT you can find it in the intro section to the Matters portion fo the documentation: https://app.clio.com/api/v4/documentation#tag/Matters
Hope this helps. I'd imagine someone at Clio could help by verifying your error string is delivered when you have an incorrect custom field value unique id.
To further clarify Jacob's answer for everyone else:
custom_field{id} is the id given to a custom_field when it's created and will be the same for all matters or contacts it's used in.
custom_field_value{id} is the id given to an instance of the custom_field added to a particular matter and unique only to that matter
To add a custom_field to a matter for the first time the following format is used:
{"data":{"custom_field_values":[{"custom_field":{"id":123456},"value":"string or integer depending on the type of CF"}]}}
To update a custom field already added to a matter the following format should be used:
{"data":{"custom_field_values":[{"id":"text_line-1234567", "custom_field":{"id":123456},"value":"string or integer depending on the type of CF"}]}}
To delete a custom field already added to a matter the following JSON format is sufficient:
{"data":{"custom_field_values":[{"id":"text_line-1234567", "custom_field":{"id":123456},"_destroy":true}]}}
Format for updating a custom field already added to a matter:
{"data":{"custom_field_values":[{"id":"unique_instance_of_your_custom_field", "custom_field":{"id":'custom_field_id'},"value":"value which should be updated"}]}}
Here, the first id field should be the unique id of this instance of your custom field. To get this value follow this documentation section, app.clio.com/api/v4/documentation#tag/Matters and the second id field is the id for the custom field itself.

Performing PostgreSQL match using OR on a JSON field

I have a model that looks like this
class Message(db.Model):
content = db.Column(JSON)
I want to perform a search on that field which contain some JSON fields
normally when I something like this it works
Message.query.filter(Message.content['summary'].cast(Unicode).match(search_term))
Now I want to use or another field if the field summary doesn't exist or is empty
using either with or without casting fails with programming error of types needs to be boolean
Message.query.filter(Message.content['summary'] | Message.content['text+video'].match(search_term))
Thanks to Elmer on the #sqlalchemy IRC channel, the logic was not correct, that's how I should have performed the search
Message.query.filter(Message.content['summary'].cast(Unicode).match(search_term) | Message.content['text'].cast(Unicode).match(search_term))
People who are interested should also follow this link where there is a related question with a better answer SQLAlchemy Text Matching data inside JSON field with UTF-8