MongoDB shell:从控制台读取一行(MongoDB shell: reading a line from the console)
有没有办法从Mongo shell中读取一行?
readline()
没有定义,也没有system.stdin
。我需要在交互模式下执行此操作,而不是将输入提供给由MongoDB shell执行的脚本。
Is there a way to read a line from the Mongo shell?
readline()
is not defined and neither issystem.stdin
.I need to do this in interactive mode, as opposed to feeding input to a script executed by the MongoDB shell.
原文:https://stackoverflow.com/questions/11333248
更新时间:2022-11-30 09:11
最满意答案
没有任何
field_for
方法。你的问题也不清楚。 你究竟想做什么? 只显示一个设备? 哪一个? 先,最后?
UPD
commercial_offer.rb:
class CommercialOffer < ActiveRecord::Base has_many :prices has_many :devices, :through => :prices accepts_nested_attributes_for :prices accepts_nested_attributes_for :devices, :allow_destroy => true end
你的看法
<%= form_for @commercial_offer do |f| %> <%= f.fields_for :devices do |device| %> <p> <%= device.check_box :_destroy %> <%= device.label "Destroy?" %> </p> <p> <%= device.text_field :name %> </p> <%= device.fields_for :prices do |builder| %> <%= render 'prices/new_price', :f => device %> <% end %> <% end %> <% end %> <div class="actions"> <%= f.submit "Save"%> </div> <% end %>
_new_price部分
<%= f.text_field :price %></br> Quantity: <%= f.text_field :quantity %></br> Device id: <%= f.text_field :device_id %></br>
There is no any
field_for
method.Also your question isn't clear. What actually you want to do? Show only one device? Wich one? First, last?
UPD
commercial_offer.rb:
class CommercialOffer < ActiveRecord::Base has_many :prices has_many :devices, :through => :prices accepts_nested_attributes_for :prices accepts_nested_attributes_for :devices, :allow_destroy => true end
Your view
<%= form_for @commercial_offer do |f| %> <%= f.fields_for :devices do |device| %> <p> <%= device.check_box :_destroy %> <%= device.label "Destroy?" %> </p> <p> <%= device.text_field :name %> </p> <%= device.fields_for :prices do |builder| %> <%= render 'prices/new_price', :f => device %> <% end %> <% end %> <% end %> <div class="actions"> <%= f.submit "Save"%> </div> <% end %>
_new_price partial
<%= f.text_field :price %></br> Quantity: <%= f.text_field :quantity %></br> Device id: <%= f.text_field :device_id %></br>
相关问答
更多-
没有任何field_for方法。 你的问题也不清楚。 你究竟想做什么? 只显示一个设备? 哪一个? 先,最后? UPD commercial_offer.rb: class CommercialOffer < ActiveRecord::Base has_many :prices has_many :devices, :through => :prices accepts_nested_attributes_for :prices accepts_nested_attributes_for ...
-
在嵌套窗体验证错误后,rails fields_for不会呈现(rails fields_for does not render after validation error on nested form)[2023-01-22]
它会抛出一个错误吗? 我的猜测是你的问题是,在你的new动作中,你正在做@property.images.build ,它不在你的编辑动作中。 当验证失败时,它将呈现您的新动作,但不会运行您的新动作。 您可以尝试将@property.images.build放置在create操作的else子句中,如: else @property.images.build render :action => 'new' end 不是以最简单的方式来做到这一点,但是如果这是你的问题,这将有助于追踪。 Does it ... -
嵌套表单不能与has_one关联和fields_for一起使用(nested forms not working with has_one association and fields_for)[2022-06-04]
class Buyers::RegistrationsController < Devise::RegistrationsController def new build_resource({}) @buyer_info = resource.build_buyer_info end end 尝试这个 class Buyers::RegistrationsController < Devise::RegistrationsController def new build ... -
在eventdate.rb模型中,将append optional: true附加到此行: belongs_to :event class Eventdate < ApplicationRecord belongs_to :event, optional: true validates :date, :start_hour, :finish_hour, :event_id, presence: true end 因为Rails将首先创建event eventdates ,然后创建event并链接 ...
-
如果你添加一个新的依赖项,你可以使用cacoon gem,它可以让你更轻松地处理嵌套表单。 这是一个额外的依赖项,但添加新关联记录的代码很简单,如下所示: <%= form_for author do |f| %> ... <%= f.fields_for :books do |book| %> <%= render 'book_fields', f: book %> <%= link_to_add_association 'add book', f, :books %> <%e ...
-
如果你想要一个全javascript方法(而不是调用你的服务器来产生字段名称),那么基本上你只需要为任何新字段增加字段名称。 例如,如果你有 class Form < ActiveRecord::Base has_many :fields accepts_nested_attributes_for :fields 并且表单中的HTML有一个类似的输入字段
相关文章
更多- MongoDB学习(三):MongoDB Shell的使用
- MongoDB shell 操作数据库
- mongodb删除文档操作-使用shell和java操作mongodb文档
- mongodb添加集合文档操作-使用shell和java操作mongodb文档
- Shell的分类
- shell是什么
- 基于linux安装MongoDB
- MongoDB学习 (四):创建、读取、更新、删除(CRUD)快速入门
- MongoDB学习(一):MongoDB 环境的搭建
- MongoDB学习 (六):查询
最新问答
更多- python的访问器方法有哪些
- 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
- 透明度错误IE11(Transparency bug IE11)
- linux的基本操作命令。。。
- 响应navi重叠h1和nav上的h1链接不起作用(Responsive navi overlaps h1 and navi links on h1 isn't working)
- 在C中读取文件:“r”和“a +”标志的不同行为(Reading a File in C: different behavior for “r” and “a+” flags)
- NFC提供什么样的带宽?(What Kind of Bandwidth does NFC Provide?)
元素上的盒子阴影行为(box-shadow behaviour on elements) - Laravel检查是否存在记录(Laravel Checking If a Record Exists)
- 设置base64图像的大小javascript - angularjs(set size of a base64 image javascript - angularjs)
- 想学Linux 运维 深圳有哪个培训机构好一点
- 为什么有时不需要在lambda中捕获一个常量变量?(Why is a const variable sometimes not required to be captured in a lambda?)
- 在Framework 3.5中使用服务器标签<%=%>设置Visible属性(Set Visible property with server tag <%= %> in Framework 3.5)
- AdoNetAppender中的log4net连接类型无效(log4net connection type invalid in AdoNetAppender)
- 错误:发送后无法设置标题。(Error: Can't set headers after they are sent. authentication system)
- 等待EC2实例重启(Wait for an EC2 instance to reboot)
- 如何在红宝石中使用正则表达式?(How to do this in regex in ruby?)
- 使用鼠标在OpenGL GLUT中绘制多边形(Draw a polygon in OpenGL GLUT with mouse)
- 江民杀毒软件的KSysnon.sys模块是什么东西?
- 处理器在传递到add_xpath()或add_value()时调用了什么顺序?(What order are processors called when passed into add_xpath() or add_value()?)
- sp_updatestats是否导致SQL Server 2005中无法访问表?(Does sp_updatestats cause tables to be inaccessible in SQL Server 2005?)
- 如何创建一个可以与持续运行的服务交互的CLI,类似于MySQL的shell?(How to create a CLI that can interact with a continuously running service, similar to MySQL's shell?)
- AESGCM解密失败的MAC(AESGCM decryption failing with MAC)
- SQL查询,其中字段不包含$ x(SQL Query Where Field DOES NOT Contain $x)
- PerSession与PerCall(PerSession vs. PerCall)
- C#:有两个构造函数的对象:如何限制哪些属性设置在一起?(C#: Object having two constructors: how to limit which properties are set together?)
- 平衡一个精灵(Balancing a sprite)
- n2cms Asp.net在“文件”菜单上给出错误(文件管理器)(n2cms Asp.net give error on Files menu (File Manager))
- Zurb Foundation 4 - 嵌套网格对齐问题(Zurb Foundation 4 - Nested grid alignment issues)
- 湖北京山哪里有修平板计算机的