Trying to write a simple code in mongoldb, receiving an error - mongodb

Just trying out MongoDB. So this might be a very basic issue. Trying to create a collection "info", but encountering errors as below. Appreciate the help.
uncaught exception: SyntaxError: missing : after property id :
#(shell):1:42
The code is as below :
db.info.insert({"userName":"John","mail”:"John#gmail.com","mobile":12345678},{"Transaction":[{"itemId":"a100","price":200},{"itemId":"a110","price":200}]},{"Payment":["Type":"Credi
t-card","Total":400,"Success":true]},{"Remarks":"1st complete record,payment successful"})

When you try, most of the developers would recommend to read the documentation of Insert data in mongodb. If you clearly understand, then you might understand the problem. The document was not well formatted which means you created object for each key:value pair. And payment is an array which holds objects. It was also not formatted.
You can try below code, and have fun with MongoDB
db.info.insert(
{
"userName":"John",
"mail":"John#gmail.com",
"mobile":12345678,
"Transaction":[{"itemId":"a100","price":200},{"itemId":"a110","price":200}],
"Payment":[{"Type":"Credit-card","Total":400,"Success":true}],
"Remarks":"1st complete record,payment successful"
}
)

Related

MongoDB update deep nested field in the document

I try to update a field in the MongoDb like this
https://mongoplayground.net/p/_jFYJGi8z46
However i get this error
fail to run update: write exception: write errors: [The array filter for identifier 'e2' was not used in the update { $set: { sizes.$[e1].wares$[e2].reserved: "2" } }]
I can't find a bug :( ... it must be a very simple one
Right... one dot was missing :( This is solved
https://mongoplayground.net/p/obdFTr6G1kj

Query In MongoDb while Insertion

I use a function insertOne to insert an object. I have place correct colon and also correct commas then why this error come. Thanks in Advance.
This is my code
db.items.insertOne({Name:"Oppo",Price:"45000",Ritems:"345",Sold:"45","Rating:"3.5",once"twos"})
Error is this
uncaught exception: SyntaxError: missing : after property id :
#(shell):1:78
>
I think that your "" are misplaced. I think this way would be better ??
db.items.insertOne({Name:"Oppo",Price:"45000",Ritems:"345",Sold:"45",Rating:"3.5",once:"twos"})
Also the error message is telling you about the Id column, you should check if you need to set it yourself or if your database has an auto-increment ID.

Error message from filter array

So I have tried to get the error message from a filter array in a logic app workflow, this is what i have tried:
#body('Filter_array')['error']
#actions('Filter_array')['outputs']['body']['error']
Am I missing something or doing something wrong here?
Thanks.
UPDATE:
It says: "cannot be evaluated because property 'error' cannot be selected. ".
But i can clearly see the "error" in the body object in the output.
Ok so i managed to figure it out, i missed the fact that the array doesnt give me a single object as i thought i set it up to. so the solution was this:
#string(actions('Filter_array')['outputs']['body'][0]['error'])
Thanks for the help! :)
Can you try with #actions('Filter_array')['error'] ?
You have to distinguish 2 types of errors.
First error can occur during execution of your connector. Eg. The filter did not match. In this case, the connector executed and returns an output with an error-message.
Second error is a runtime error that can occur on the connector. For example if the input of your connector is invalid and the executing of the connector can't be triggered. In this case, the connector does not generate an output or result. In that case, you have to catch the exception with #actions('Filter_array')['error']

How do I structure my Geofire posts in my firebase database

I have noticed on all other posts that any node/key with children was saved in the database in quotes and mine are not.
mine
Locations{
indexOn: "g"
}
others/what I assume it should be
Locations{
".indexOn": "g"
}
I didn't think anything of it till I came up on a similar error as this with the ".indexOn". I tried adding ".indexOn" but i received the error that no key can have the symbol .(along with a few other characters that aren't allowed) so I put it in without the . like so:
Locations{
(specific id){
g: "345jh3i5jh"
l{
0: 37
1: -120
}
indexOn: "g"
user: "0987435098723098Gjhf90"
}
}
So It seems to work as the observeEventType is returning the correct result sometimes but it still also gives me the error that i need to put ".indexOn" in database. How do I do this?
Any help and explicit examples would be appreciated as there are probably more problems with everything than I addressed. Doing this in swift and thanks for the read!
You seem to be trying to add index definitions to your database. That is indeed a great way to ensure the server can order and filter the data before returning the results to your app.
Indexes are defined by adding them to your Firebase Database rules in the Firebase Console > Database > Rules. Don't try to add them to your actual database, since:
you won't be able to save them, since they have a . in their key, which is an illegal character in the database
adding them won't help, since the database server only searches for .indexOn definitions in the database rules
See the Firebase documentation on adding indexes for more.

Crash with Lucene.NET when using Sort

I have a date field inserted in a Lucene database with the following code:
Document.Add(new NumericField("TimeStamp", Field.Store.YES, true).SetLongValue(Data.TimeStamp.ToBinary()));
And I have the following query:
var Sort = new Sort(new SortField("TimeStamp", SortField.LONG, true));
var ParsedQuery = ParseQuery(_Parser, SearchQuery);
var Filter = new QueryWrapperFilter(ParsedQuery);
var Hits = _Searcher.Search(ParsedQuery, Filter, Skip + Limit, Sort);
But it crashes when executing the search method with the following:
A first chance exception of type 'Lucene.Net.QueryParsers.QueryParser.LookaheadSuccess' occurred in Lucene.Net.dll
A first chance exception of type 'System.IO.IOException' occurred in Lucene.Net.dll
A first chance exception of type 'System.IO.IOException' occurred in Lucene.Net.dll
A first chance exception of type 'System.AccessViolationException' occurred in HDIndexing.dll
Additional information: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
If I replace the Sort variable with one of the constants, such as Sort.RELEVANCE then the search works properly.
The problem comes from my custom search.
Incidentally I noticed something else odd and I do not know if these is a connection: If I inspect my Lucene DB with the Luke tool, all my fields are reported to be strings:
http://i.stack.imgur.com/SnlSD.png
I do not know if this is a bug in Luke or something is wrong with how Lucene is set up on my end.
I tried to change the sort to a type 'string' to see what would happen, but it crashes the same way, so either way, the type of the field doesn't seem to have an impact.
Has anyone experienced that problem before?
It could be similar to someone else's post: lucene.net sort not working access violation