2

I lovely update a document with values(Maps coord) from clienside (under privileges). MongoDB use javascript in some internals functions and for MapReduce but is not clear for me if i can use client side scripts to update my repository with values. I searching to pass values from client side to an updater Db.Repository.Updater(item). It's possible to make this using javascript or need a webservice or a rest function.

Can some expert clarify this point and suggest the way.
Many thanks.

1 Answer 1

1

There is http interface in mongodb, so you can send direct update request to mongodb through $.ajax for example, or you can send ajax requests to yours handlers/pages/controllers and use mongo-csharp driver as usual for updates. Make your choise...

Include jquery at page first. In 'Update' button click handler paste code like this(to send ajax request):

$.ajax({
   type: "POST",
   url: "SomePage.aspx",
   data: "name=John&location=Boston",
   success: function(msg){
     alert( "Data Saved: " + msg );
   }
 });

In page(but it seems to me that better to use http hadlers ajax handling):

public void Page_Load(object sender, EventArgs e)
{
  var name = HttpContext.Current.Request["name"];
  var location = HttpContext.Current.Request["location"];
  var item = new Item(){Name = name, Location = location};
  //here update or insert your item, do what you want
  Db.Repository.Updater(item)
}
Sign up to request clarification or add additional context in comments.

2 Comments

Um Bugai13, Can you help me litle more in the second case. I have seen Rest interfaces docs with Node and test files but it's not very clear for me. Can you submit a simple sample.tks
I don't understand what directly you want, but I a little explained secod case. Please, clarify you question if you need something else.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.