如何使用rails在mongo db中附加数据

时间:2015-05-30 11:23:58

标签: mongodb ruby-on-rails-4

我正在使用void mainImage( out vec4 fragColor, in vec2 fragCoord ) { vec2 uv = fragCoord.xy / iResolution.xy; uv -= 0.5; uv *= vec2(iResolution.x/iResolution.y,1.0); uv += 0.5; float d = sdAxisAlignedRect(uv, vec2(0.3), vec2(0.7)); float m = 1.0 - abs(d)/0.1; float s = sin(d*400.0) * 0.5 + 0.5; fragColor = vec4(s*m*(-sign(d)*0.5+0.5),s*m*(sign(d)*0.5+0.5),0,1); } 以及 @{ Layout = null; } <!DOCTYPE html> <html ng-app="exampleapp"> <head> <meta name="viewport" content="width=device-width" /> <script src="~/Scripts/jquery-1.10.2.min.js"></script> <title>Directives</title> <link href="~/Content/bootstrap.css" rel="stylesheet" /> <style> .bold { font-weight:bold; } .red { color:red; } .green { color:blue; } </style> <script src="~/Scripts/angular.js"></script> <script> angular.module("exampleapp", []).directive("unorderedList", function (){ return { link: function (scope, element, attrs) { scope.data=scope[attrs["unorderedList"]]; }, restrict: "M", template:"<ul><li ng-repeat='item in data'>{{item.price | currency}}</li></ul>" } }).controller("defaultctrl", function ($scope) { $scope.products = [{ name: "Apples", category: "Fruit", price: 1.20, expiry: 10 },{ name: "Bananas", category: "Fruit", price: 2.42, expiry: 7 },{ name: "Pears", category: "Fruit", price: 2.02, expiry: 6 } ]; $scope.incrementprices = function () { for(var i=0;i<$scope.products.length;i++) { $scope.products[i].price++; } }; }); </script> </head> <body ng-controller="defaultctrl" > <h3>Fruit</h3> <!-- directive:unordered-list products --> </body> </html> rails 4.1.8 gem连接到ruby 2.1.2p95。我已阅读此document但它并未提供我们如何将数据附加到文档的现有行中。此外,任何人都可以提供任何其他文档链接,它提供了从rails连接到mongo的广泛语法。

以下代码不会附加数据,而是会创建一个新行:

mongo-2.0.4

代码:

mongo db v3.0.3

插入以下行后:

 mongo_con.find(:chatid => 5678).update_one('$set' =>  {:chat => 'this is  are you'})

我想在前一行中追加这一行:

require 'mongo'
db = Mongo::Client.new([ '192.168.56.102:27017' ], :database => 'stackoverflow')

0 个答案:

没有答案