V
V
Vadim Ivanenko2017-01-25 14:46:32
MongoDB
Vadim Ivanenko, 2017-01-25 14:46:32

How to call stored JavaScript through .NET?

I need to select items from a collection using multiple filters (From Most Accurate to Least).
For example:
1 filter looks for items in 5 fields. It returns everything that it has found with flag 0.
If we did not find several records by 1 filter, then we try to find these records by a less accurate match (by 3 fields, for example). We return them with the -1 flag. Etc.
I would like to implement this with a stored function on the Mongi side and pull it from .NETa once.
I can call the storage only from the robomongi shell. From .NET, this cannot be done.

var cmd = new JsonCommand<BsonDocument>("{ eval: \"GetData()\" }");
var result = collection.Database.RunCommand(cmd);

Only some meta-information about the database and the collection is returned in result. Brought it to JSON. No data.
Storage code
var result = db.getCollection('mydata').find({
    'prop1': 'FOO',
    'prop2': '123',
    });
    return result;

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ivan Filatov, 2017-01-25
@NYMEZIDE

Connect ElasticSearch better. You will make a request to it, get IDs of mongo documents - pick up documents by id. As an option.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question