Source: site.view [edit]
Function name: copyDB
Arguments: from,to
Description:
Page type: webl
Render function:  
Module: demavu

Page source:

var db = Wub_GetDB("demavu");

var coll = Wub_GetCollection(db, "data");

from = Str_Trim(from);
to = Str_Trim(to);

// reset all the data on the "to" server
var queryObj = Wub_NewDBObject([. "server"=to .]);
/// Wub_RemoveDB(coll, queryObj);

queryObj = Wub_NewDBObject([. "server"=from .]);

var objs = Wub_QueryDB(coll, queryObj, 50000);

every obj in objs do
   obj["server"] := to;
   var dbobj = Wub_NewDBObject(obj);
   Wub_InsertDB(coll, dbobj);
 
end;

var s = WubCall("toJSON", [Size(objs)]);
NewPage(s, "text/plain");