Linx Main Linx Help

Using MongoDBWrite with UpdateOperation


#1

Hi,

Could you please provide an example of using MongoDBWrite component with “Update” operation? It’s not clear for me how to use correctly the “Criteria” and “Update operation” content. I would like, for example, to increase a counter for a given mongoDB document identified by a unique string property.

Thank you in advance.

Regards,
Ivan


#2

Hello,

Please, does anybody can help me on this topic?

Thank you,
Ivan


#3

Hi Ivan,

Unfortunately my experience with MongoDB is very close to 0. I’ll try and find someone with a bit more XP in it.

Regards,
Dawie


#4

Thank you Dawie, hope to hear from you soon.

Regards,
Ivan


#5

Ivan

Here is a sample on how to increment a property in MongoDb using Linx.

The sample data

{"model":"Ford","year":"2000","stock":5}
{"model":"Ferrari","year":"2010","stock":1}

To get the attached Linx solution sample to work do the following

  1. Fix the DbConnection in Settings to point to your MongoDb.
  2. Run AddCars to add the sample data.
  3. Run GetCar. Set model = Ford in debug values. Check that it returned the Ford.
  4. Run IncrementStock. Set model = Ford in debug values. Check that 5 became 6.

The IncrementStock process uses the MongoDbWrite function with the $inc operator to increment the stock property.

inc

MongoDbSample.lsoz (6.4 KB)


#6

Thank you very much, it’s clear and very useful!

Regards,
Ivan