小编Joh*_*yHK的帖子

将所有行复制到Azure表存储中的另一个表

将所有行从一个表复制到另一个表的最佳方法是什么?
我尝试下面的代码来获取表中的所有行:

    TableServiceContext _dataContext;
    public IEnumerable<T> GetAllEntities()
    {
        IQueryable<T> query = null;
        try
        {
            query = _dataContext.CreateQuery<T>(_tableName);
        }
        catch (Exception ex)
        {

        }
        return query.ToArray();
    }
Run Code Online (Sandbox Code Playgroud)

但它不会超过900左右的行.我有几十万行.
更新的代码:

 public class TableRepository<T> : IRepository<T> 
    where T : TableEntity
{
    protected readonly string _tableName;
    protected readonly TableServiceContext _dataContext;
    protected readonly CloudTable _tableReference;

    public TableRepository(string tableName, CloudTableClient tableClient)
    {
        _tableName = tableName;
        _dataContext = tableClient.GetTableServiceContext();
        _tableReference = tableClient.GetTableReference(tableName);
        _dataContext.ResolveType = ResolveEntityType;
        _dataContext.MergeOption = System.Data.Services.Client.MergeOption.NoTracking;
    }

    public IEnumerable<T> GetAllEntities()
    {
        List<T> allEntities = new …
Run Code Online (Sandbox Code Playgroud)

c# azure azure-storage azure-table-storage

5
推荐指数
1
解决办法
5164
查看次数

node.js async.eachSeries太早调用最终回调

这就是我想要的:我有一个叫做结果的大数组.我希望将该数组中的每个项放入我的迭代函数中并将其保存到我的mongoDB中(我在这里省略了一些不重要的步骤).在将这些项目中的每一项保存到数据库(或拒绝)之后,我希望console.log显示"All done".不幸的是,所有完成都会在调用系列后立即显示,而其他所有内容仍在处理中.我该怎么做?

我正在使用mongoose和一个名为'light'的模型,为了便于阅读,我省略了代码中的所有错误消息.我对eachSeries部分使用node-async

var async = require('async');    
var results = [very big array]
var iteration = function(row,callbackDone) {
  light.find({data: row.data}, function (err,entry) {
    if(entry.length) {
      callbackDone();
      return console.log(entry + ' already exists');
    }
    var newEntry = new light(row);
    newEntry.save(function (err,doc) {
      console.log(entry + ' saved');
      callbackDone();
    });
  });
};

async.eachSeries(results,iteration, function (err) {
  console.log('All done');
});
Run Code Online (Sandbox Code Playgroud)

javascript asynchronous mongodb node.js

5
推荐指数
1
解决办法
1万
查看次数

使用pymongo在Mongodb中检查数据库

如何使用pymongo在mongodb中检查是否存在数据库的异常处理.

谢谢.

mongodb pymongo

5
推荐指数
1
解决办法
4582
查看次数

无法连接到mongodb

我是关于node.js和mongodb的新手.

我已经安装了mongodb,但我无法连接到mongodb.

这是我的错误:

Huys-MacBook-Pro:~ huy$ mongo
MongoDB shell version: 2.0.2
connecting to: test
Tue Jan  3 17:12:01 Error: couldn't connect to server 127.0.0.1 shell/mongo.js:84
exception: connect failed
Run Code Online (Sandbox Code Playgroud)

mongoose mongodb node.js

4
推荐指数
2
解决办法
1万
查看次数

如果我没有回调函数,Mongoose不会更新我的文档

这是我的模特:

var UserSchema = new Schema({
    username: { type: String, unique: true, index: true },
    url: { type: String },
    name: { type: String },
    github_id: { type: Number },
    avatar_url: { type: String },
    location: { type: String },
    email: { type: String },
    blog: { type: String },
    public_repos: { type: Number },
    public_gists: { type: Number },
    last_github_sync: { type: Date },
    created_at: { type: Date, default: Date.now }
});
Run Code Online (Sandbox Code Playgroud)

我尝试用findOneAndUpdate函数更新我的文档:

不起作用:

User.findOneAndUpdate({ github_id: 1 …
Run Code Online (Sandbox Code Playgroud)

mongoose mongodb node.js

4
推荐指数
1
解决办法
2886
查看次数

Microsoft Azure定价 - 什么构成出站流量?

根据Azure定价网站:

发送到Windows Azure的所有入站数据都是免费的.根据在给定计费周期内通过Internet移出Windows Azure数据中心的数据总量来计算出站数据.位于同一数据中心内的Windows Azure服务之间的数据传输不收取任何费用.每个结算月份的前5 GB出站数据传输也是免费的.

所以我有以下问题:

  1. 如果我使用Azure来托管一个大小为100MB的SQL Azure数据库的网站,如果没有人访问我的网站(因此没有出站流量),我的唯一成本是5美元/月.对于100MB DB?

  2. 当我的MVC 4应用程序从SQL Azure数据库请求数据,并且数据库返回数据时,这是否算作"出站数据"?或者是出站数据只有从我的网站到任何客户端访问网站的数据?

azure

4
推荐指数
1
解决办法
3069
查看次数

如何格式化Mongoose调试输出 - 漂亮的打印

如何在控制台中使Mongoose调试输出看起来很漂亮?目前输出显示在一行上.

console mongoose node.js

4
推荐指数
1
解决办法
1498
查看次数

mongoose:如何插入单个子文档 - 而不是数组

在mongoose中,您可以按照以下方式声明子文档的模式:

        var childSchema = new mongoose.Schema({ name: String, age: String });
        var parentSchema = new mongoose.Schema({
            children: [childSchema]
        });
        var Parent = mongoose.model('Parent', parentSchema);
        var Child = mongoose.model('Child', childSchema);

        var child = new Child({name:'Joe', age: '21'});
        var parent = new Parent();

        parent.children = [child];

        parent.save(function(err, saved) {
            if(err) console.error(err);
        });
Run Code Online (Sandbox Code Playgroud)

似乎子文档类型需要是一个数组.我需要能够将子文档保存为单个实例,而不是数组,即:

        var childSchema = new mongoose.Schema({ name: String, age: String });
        var parentSchema = new mongoose.Schema({
            children: childSchema // not an array
        });
        var Parent = mongoose.model('Parent', parentSchema);
        var Child …
Run Code Online (Sandbox Code Playgroud)

mongoose mongodb node.js

4
推荐指数
2
解决办法
1万
查看次数

如何将属性添加到我不想持久的js-data对象?

我通过sails.js将js-data(和js-data-angular)与套接字结合使用.当通过套接字创建/更新新项目时,我想在我的ui中引起注意.

我想向对象添加"更新"属性,但不希望无意中将其持久保存到数据库中.

有没有办法在js-data对象上挂起非持久性属性?

sails.js jsdata

4
推荐指数
1
解决办法
237
查看次数

使用C#MongoDB驱动程序的嵌套数组$ pull查询

我按照预期在mongo shell上运行以下查询.

db.getCollection('personnels').update(
    {
        _id: ObjectId("55f6728b9d73a15807885de8"), 
        "Devices._id":ObjectId("55fa5f7ac9e7863a3836e331")
    }, 
    {
        $pull:{ "Devices.$.DeviceCloudFolders": { "CloudFolderId": ObjectId("5615124b06275f072040c4f1")}}
    }
);
Run Code Online (Sandbox Code Playgroud)

这是我的文档结构:

{
    "_id" : ObjectId("55f6728b9d73a15807885de8"),
    "FirstName" : "Tolga",
    "Devices" : [ 
        {
            "_id" : ObjectId("55fa5f7ac9e7863a3836e331"),
            "Name" : "tolga-laptop",
            "DeviceCloudFolders" : [{
                "AuthorityType" : 1,
                "CloudFolderId" : ObjectId("55f96db5c9e7863a3836e310"),
                "Status" : 1
            }],
            "Status" : 1
        }
    ],
    "Status" : 1
}
Run Code Online (Sandbox Code Playgroud)

我需要在C#中使用它并且无法弄清楚如何使用它.

我从这些线开始:

var filter = Builders<Personnel>.Filter.And(
                 Builders<Personnel>.Filter.Eq("_id", ownerPersonnelId),
                 Builders<Personnel>.Filter.Eq("Devices._id", _id));

var update = Builders<Personnel>.Update.PullFilter("Devices.$.DeviceCloudFolders", /*couldn't figure out what goes here*/))

Personnels.FindOneAndUpdateAsync(filter, update);
Run Code Online (Sandbox Code Playgroud)

c# shell mongodb

4
推荐指数
1
解决办法
2184
查看次数