$$hashKey 不得以“$”开头 Deployd
$$hashKey must not start with '$' Deployd
嗨,当我 post 部署时,我在控制台中收到这个奇怪的错误
Object {name: "MongoError", message: "key $$hashKey must not start with '$'", status: 400}
代码
dpd.timesheetsdone.post({
"projectId": $scope.projectId ,
"formandSig": $scope.signature,
"timesheets": $scope.timesheets
}, function (result, err) {
if (err) return console.log(err);
console.log(result, result.id);
});
项目 ID 和签名是一个简单的字符串,时间表是一个数组
如果我用
替换scope.timesheets
[
{
"projectId": "1000",
"date": "2015-05-15T22:00:00.000Z",
"start": "25200"
}
]
有效..
onsole.log(scope.timesheet... returns 具有相同值的对象 + 和散列键
Angular 自动将 $$hashKey
添加到 $scope.timesheets
数组中的所有对象。您可以通过 angular.toJson($scope.timesheets)
摆脱这些
所以你的 post 看起来像这样:
dpd.timesheetsdone.post({
"projectId": $scope.projectId ,
"formandSig": $scope.signature,
"timesheets": angular.toJson($scope.timesheets)
...
已将散列键解析时间表删除到 JSON
不知道这是否是删除哈希键的正确/最佳方法?
$scope.sign = function() {
var sheets = angular.toJson($scope.timesheets);
var sheets = JSON.parse(sheets);
dpd.timesheetsdone.post({
"projectId": $scope.projectId ,
"formandSig": $scope.signature,
"timesheets": sheets
}, function (result, err) {
if (err) return console.log(err);
console.log(result, result.id);
});
}
嗨,当我 post 部署时,我在控制台中收到这个奇怪的错误
Object {name: "MongoError", message: "key $$hashKey must not start with '$'", status: 400}
代码
dpd.timesheetsdone.post({
"projectId": $scope.projectId ,
"formandSig": $scope.signature,
"timesheets": $scope.timesheets
}, function (result, err) {
if (err) return console.log(err);
console.log(result, result.id);
});
项目 ID 和签名是一个简单的字符串,时间表是一个数组
如果我用
替换scope.timesheets [
{
"projectId": "1000",
"date": "2015-05-15T22:00:00.000Z",
"start": "25200"
}
]
有效..
onsole.log(scope.timesheet... returns 具有相同值的对象 + 和散列键
Angular 自动将 $$hashKey
添加到 $scope.timesheets
数组中的所有对象。您可以通过 angular.toJson($scope.timesheets)
所以你的 post 看起来像这样:
dpd.timesheetsdone.post({
"projectId": $scope.projectId ,
"formandSig": $scope.signature,
"timesheets": angular.toJson($scope.timesheets)
...
已将散列键解析时间表删除到 JSON 不知道这是否是删除哈希键的正确/最佳方法?
$scope.sign = function() {
var sheets = angular.toJson($scope.timesheets);
var sheets = JSON.parse(sheets);
dpd.timesheetsdone.post({
"projectId": $scope.projectId ,
"formandSig": $scope.signature,
"timesheets": sheets
}, function (result, err) {
if (err) return console.log(err);
console.log(result, result.id);
});
}