为什么mongoDB使用objectID?(Why mongoDB uses objectID?)

{ "_id" : ObjectId("4c2209f9f3924d31102bd84a"), "name" : "mongo" }

objectId究竟是什么目的? 这是使用时间戳生成的大数字。

如果我看到任何nosql是键值,我用键查询值。

这里我们使用key和value作为数据并使用find()函数。

那么,我想知道什么时候我们真的需要objectid? 授予用户访问权限以查看对象ID值的原因是什么?

阅读文档后,一个基本问题是mongo DB作为哈希表类型实现?


{ "_id" : ObjectId("4c2209f9f3924d31102bd84a"), "name" : "mongo" }

what exactly is the purpose of objectId? It's a big number that is generated using a timestamp.

If I see any nosql which is key-value, I query with key the value.

Here we use key and value in the as the data and use find () function.

So, I am trying to understand when we really need the objectid? What are the reasons behind that giving access to the user to view the value of the object ID?

After reading the docs, one basic question is mongo DB as hash table type implementation?


原文:https://stackoverflow.com/questions/6560928
2022-07-05 07:07

满意答案

我用了

  type: "GET",
  url: "http://stackoverflow.com/questions/32554239/ajax-post-without-refresh", 

而不是你的

   type: "POST",
  url: "http://****/new/action.php",  

它工作正常。 (只需点击“运行代码段”,它会显示错误,因为该网址不支持跨域)

$(document).ready(function() {  
  $("form#iscrizione").submit(function(){   
    var ordine = $("#ordine").val();  
    var cognome = $("#cognome").val();
    $.ajax({  
      type: "GET",
      url: "http://stackoverflow.com/questions/32554239/ajax-post-without-refresh",  
      data: "cognome=" + cognome + "&ordine=" + ordine,
      dataType: "html",
      success: function(risposta) {  
        $("div#risposta").html(risposta);  
        alert("ok!");
      },
      error: function(){
              alert("Chiamata fallita!!!");
}
    }); 
    return false;  
  });
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<form id="iscrizione"> 
  
  <input type="text" value="get" id="cognome"><input type="text" value="get" id="ordine"><input type="submit" value="get"></form><div id="risposta"></div>


I used

  type: "GET",
  url: "http://stackoverflow.com/questions/32554239/ajax-post-without-refresh", 

instead of your

   type: "POST",
  url: "http://****/new/action.php",  

AND it works fine. (Just click on "Run snippet", it shows an error because the url doesn't support cross-domain)

$(document).ready(function() {  
  $("form#iscrizione").submit(function(){   
    var ordine = $("#ordine").val();  
    var cognome = $("#cognome").val();
    $.ajax({  
      type: "GET",
      url: "http://stackoverflow.com/questions/32554239/ajax-post-without-refresh",  
      data: "cognome=" + cognome + "&ordine=" + ordine,
      dataType: "html",
      success: function(risposta) {  
        $("div#risposta").html(risposta);  
        alert("ok!");
      },
      error: function(){
              alert("Chiamata fallita!!!");
}
    }); 
    return false;  
  });
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<form id="iscrizione"> 
  
  <input type="text" value="get" id="cognome"><input type="text" value="get" id="ordine"><input type="submit" value="get"></form><div id="risposta"></div>

相关问答

更多

如何在成功发布AJAX后更新值/刷新页面(How to update values/refresh page after successful AJAX post)

你永远不会输入你的ajax调用的success函数:你已经将dataType设置为json所以jQuery期望json返回。 但是,您正在发回html。 你应该从你的ajax调用中删除dataType: "json", : $.ajax({ type: "POST", url: "auction-handler.php", // Or remove this, or send json back // dataType: "json"...

AJAX间隔刷新?(AJAX Interval Refresh?)

考虑使用setTimeout来代替 - 它更可靠。 当窗口没有焦点时, setInterval定时器可以堆叠,然后当它再次获得焦点时,它们都会立即运行。 使用setTimeout还可以确保如果第一个AJAX请求由于某种原因而阻塞,则不会获得排队的多个AJAX请求。 要立即开始循环,请使用环绕该函数的IIFE(“立即调用的函数表达式”): (function update() { $.ajax({ ... // pass exis...

如何在ajax post回调后刷新KendoUi网格(How to refresh the KendoUi grid after a ajax post callback)

这只是一个例子 $.ajax({ url: '@Url.Action("NewGridView", "Test")', type: "Post", data: { sampleItem: sampleItem, sampleCode: sampleCode, sampledescription: sampledescription }, dataType: 'json', success: fun...

Ajax发布没有刷新(Ajax post without refresh)

我用了 type: "GET", url: "http://stackoverflow.com/questions/32554239/ajax-post-without-refresh", 而不是你的 type: "POST", url: "http://****/new/action.php", 它工作正常。 (只需点击“运行代码段”,它会显示错误,因为该网址不支持跨域) $(document).ready(function() { $("form#iscr...

页面刷新时的Ajax POST?(Ajax POST on page refresh?)

我最终找到了答案,所以我想把它发布在这里,希望有人可能会发现它有用。 在success()回调中,我添加了以下代码: $("#subscribe-form")[0].reset(); 谢谢,加文 i eventually found the answer to this, so thought i'd post it on here, and hopefully someone may find it useful in the future. Within the success() call...

使用ajax刷新div内容(Using ajax to refresh a div content)

您正在向整个文档发送XMLHTTPRequest而不是PHP的一部分(正如我从您的问题中理解的那样,您需要的是后者)。 另外,您将请求发送到同一当前页面info.php ,最好通过将PHP代码分成两部分来分离问题(一个是呈现初始形式,另一个是用于处理服务器端的部分) )。 因此,AJAX将返回info.php所有结果(静态标记+生成的标记)并返回所有最终HTML并将其加载到.ld 。 我建议创建两个文件: form.php和process-form.php当form.php ready文档read...

MVC Core使用ajax发布数据并刷新页面上的部分(MVC Core use ajax to post data and refresh a section on the page)

如果您想用新添加的产品更新页面的某个部分,可以采用多种方式进行 1.用新的ajax调用重新加载整个列表 当您的ajax调用保存新产品成功时,您可以再次调用ajax调用以重新加载整个列表。 您将在第一次ajax调用的done事件中进行此调用。 例如,假设您以表格数据形式在页面中呈现产品列表 <div id="product-list" data-url="@Url.Action("ProductList")"> <!-- Your code to render the table which d...

Laravel 5在AJAX发布后刷新HTML(How to refresh HTML after AJAX post)

我会将导航栏包装成这样的div: <div id="ajax-nav"> <!-- Nav here --> </div> 然后,当您的登录响应成功时,您可以重新加载导航栏: $('#ajax-nav').load("some url that returns the html of the navbar"); 然后你只需要一条通向Controller的路线,该路由器可以根据用户登录状态(登录或访客)生成导航栏。 通过此过程,您可以在成功登录等特定事件后用新生成的导航栏完全替换导航栏的内容,或...

jQuery刷新表后是$ .ajax发送(jQuery Refresh table after is $.ajax send)

DataTables可以如https://datatables.net/examples/data_sources/server_side.html和https://datatables.net/reference/option/ajax中的示例所示进行提供 如下更改您的代码: /* SHOW - message */ sweetAlert({ title: 'Are You Sure?', ...

相关文章

更多

MongoDB _id和ObjectId详解

在创建一个文档的时候,会生成一个_id,id的默认类型是ObjectId,如: &gt; db. ...

Mongodb与spring集成(2)------实体映射

spring-data-mongodb中的实体映射是通过 MongoMappingConverter这 ...

MongoDB数据类型

MongoDB的文件存储格式为BSON,同JSON一样支持往其它文档对象和数组中再插入文档对象和数组, ...

MongoDB的体系结构_深入浅出MongoDB(三)

MongoDB和关系数据库逻辑结构关系对比,数据存储结构,MongoDB数据类型

MongoDB学习 (六):查询

本文将介绍操作符的使用,配合操作符,我们可以执行更加复杂的操作。 目录 查询操作 ...

solr mongoDB 对比

1 solr 字段是写死的 2 solr优势是大块文本模糊查询,mongoDB还支持正则查询以及类似j ...

mongodb删除文档操作-使用shell和java操作mongodb文档

删除集合中的文档,使用命令 db.集合名称.remove({删除条件}),例如,db.c1.remov ...

使用Java操作MongoDB_深入浅出MongoDB(五)

实现MongoDB的CRUD操作,创建一个Mongo对象,获取数据库连接,获取集合对象,返回集合中所有 ...

mongodb添加集合文档操作-使用shell和java操作mongodb文档

查看当前数据库中所有的集合,使用命令 show collections 或使用show tables ...

深入浅出MongoDB(一):认识MongoDB

MongoDB简介:面向集合(Collenction-Orented),模式自由(schema-fre ...

最新问答

更多

您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)

将diff文件复制到存储库的根目录,然后执行以下操作: git apply yourcoworkers.diff 有关apply命令的更多信息, apply 见其手册页 。 顺便说一下:一个更好的方法是通过文件交换整个提交文件是发送者上的命令git format-patch ,然后在接收器上加上git am ,因为它也传送作者信息和提交信息。 如果修补程序应用程序失败,并且生成diff的提交实际上在您的备份中,则可以使用尝试在更改中合并的apply程序的-3选项。 它还适用于Unix管道,如下

将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)

尝试将第二行更改为snprintf(buf1, sizeof buf1, "%.2f", balance1); 。 另外,为什么要声明用该特定表达式分配缓冲区的存储量? EDIT @LưuVĩnhPhúc在下面的评论中提到我的原始答案中的格式说明符将舍入而不是截断,因此根据如何在不使用C舍入的情况下截断小数,您可以执行以下操作: float balance = 200.56866; int tmp = balance1 * 100; float balance1 = tmp / 100.0; c

OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)

这是简单的解决方案 在你需要写的控制器中 BackendMenu::setContext('Archetypics.Team', 'website', 'team'); 请参阅https://octobercms.com/docs/backend/controllers-views-ajax#navigation-context BackendMenu::setContext('Author.Plugin name', 'Menu code', 'Sub menu code'); 你需要在r

页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)

每当发出请求时ASP都会创建一个新的Page对象,并且一旦它将响应发送回用户就不会保留对该Page对象的引用,因此只要你找不到某种方法来保持生命自己引用该Page对象后,一旦发送响应, Page和只能通过该页面访问的所有对象才有资格进行垃圾回收。 ASP creates a new Page object whenever a request is made, and it does not hold onto the reference to that Page object once it

codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)

要在生产服务器中调试这个,你可以临时放 error_reporting(E_ALL); 并查看有哪些其他错误阻止正确的重定向。 您还应该检查生产服务器发送的响应标头。 它是否具有“缓存”,是否需要重新验证标头等 to debug this in production server, you can temporary put error_reporting(E_ALL); and see what other errors are there that prevents the proper

在计算机拍照在哪里进入

打开娥的电脑.在下面找到视频设备点击进去就可以了...

使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)

你是对的。 第一次输入后,换行符将保留在输入缓冲区中。 第一次读取后尝试插入: cin.ignore(); // to ignore the newline character 或者更好的是: //discards all input in the standard input stream up to and including the first newline. cin.ignore(numeric_limits::max(), '\n'); 您必须为#inc

No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)

for (int k = 0; k > 10; k++) { System.out.println(k); } k不大于10,所以循环将永远不会执行。 我想要什么是k<10 ,不是吗? for (int k = 0; k < 10; k++) { System.out.println(k); } for (int k = 0; k > 10; k++) { System.out.println(k); } k is not greater than 10, so loop

单页应用程序:页面重新加载(Single Page Application: page reload)

优点是不注销会避免惹恼用户,以至于他们会想要杀死你:-)。 说真的,如果每次刷新页面时应用程序都会将我注销(或者在新选项卡中打开一个链接),我再也不会使用该应用程序了。 好吧,不要这样做。 确保身份验证令牌存储在刷新后的某个位置,即不在某些JS变量中,而是存储在cookie或本地存储中。 The advantage is that not logging off will avoid pissing off your users so much that they'll want to kill

在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)

EXECUTE IMMEDIATE 'SELECT '||field_val_temp ||' FROM tableb WHERE function_id = :func_val AND rec_key = :rec_key' INTO field_val USING 'STDCUSAC' , yu.rec_key; 和, EXECUTE IMMEDIATE 'UPDATE tablec SET field_val_'||i||' = :field_val' USI