Reputation: 1433
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.
Upvotes: 2
Views: 661
Reputation: 53685
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)
}
Upvotes: 1