免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2235 | 回复: 0
打印 上一主题 下一主题

[MongoDB] use MongoDB::OID; [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2011-12-23 02:11 |只看该作者 |倒序浏览
<DIV>#!/usr/bin/perl</DIV>
<DIV>use warnings;<BR>use strict;</DIV>
<DIV>use Data::Dumper;</DIV>
<DIV>use MongoDB;<BR>use MongoDB::OID;</DIV>
<DIV>my $con = MongoDB::Connection-&gt;new;</DIV>
<DIV>my $db = $con-&gt;syncrobid;</DIV>
<DIV>my $account_col = $db-&gt;account;</DIV>
<DIV>$account_col-&gt;remove;</DIV>
<DIV>my $account_data = {</DIV>
<DIV>&nbsp;# _id will be created automatically</DIV>
<DIV>&nbsp;company_name =&gt; '',<BR>&nbsp;username =&gt; '',</DIV>
<DIV>&nbsp;subscription_id =&gt; '', # used for Authorize.net</DIV>
<DIV>&nbsp;fax =&gt; '',<BR>&nbsp;phone =&gt; '',</DIV>
<DIV>&nbsp;address =&gt; {<BR>&nbsp;&nbsp;street =&gt; '',<BR>&nbsp;&nbsp;city =&gt; '',<BR>&nbsp;&nbsp;state =&gt; '',<BR>&nbsp;&nbsp;zip =&gt; ''<BR>&nbsp;},</DIV>
<DIV>&nbsp;users =&gt; [<BR>&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;_id =&gt; MongoDB::OID-&gt;new,</DIV>
<DIV>&nbsp;&nbsp;&nbsp;f_name =&gt; '',<BR>&nbsp;&nbsp;&nbsp;l_name =&gt; '',<BR>&nbsp;&nbsp;&nbsp;phone =&gt; '',<BR>&nbsp;&nbsp;&nbsp;ext =&gt; '',<BR>&nbsp;&nbsp;&nbsp;mobile =&gt; '',<BR>&nbsp;&nbsp;&nbsp;email =&gt; '',<BR>&nbsp;&nbsp;&nbsp;tasks =&gt; [ '', '', '' ],</DIV>
<DIV>&nbsp;&nbsp;&nbsp;settings =&gt; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;admin =&gt; 1,<BR>&nbsp;&nbsp;&nbsp;&nbsp;block_email =&gt; 1<BR>&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;}<BR>&nbsp;],</DIV>
<DIV>&nbsp;projects =&gt; [<BR>&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;_id =&gt; MongoDB::OID-&gt;new,<BR>&nbsp;&nbsp;&nbsp;name =&gt; '',<BR>&nbsp;&nbsp;&nbsp;area =&gt; '',<BR>&nbsp;&nbsp;&nbsp;union_status =&gt; '',<BR>&nbsp;&nbsp;&nbsp;users =&gt; [], # Like a has_many relationship, retrieve to get a list of users ids that are working on this current project<BR>&nbsp;&nbsp;&nbsp;task =&gt; [ qw// ],<BR>&nbsp;<BR>&nbsp;&nbsp;&nbsp;revision =&gt; [<BR>&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_id =&gt; MongoDB::OID-&gt;new,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;name =&gt; '',<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;due_date =&gt; DateTime-&gt;now,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;created_timestamp =&gt; DateTime-&gt;now,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;files =&gt; [ qw// ]<BR>&nbsp;&nbsp;&nbsp;&nbsp;},<BR>&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_id =&gt; MongoDB::OID-&gt;new,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;name =&gt; '',<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;due_date =&gt; DateTime-&gt;now,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;created_timestamp =&gt; DateTime-&gt;now,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;files =&gt; [ qw// ]<BR>&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;],</DIV>
<DIV>&nbsp;&nbsp;&nbsp;settings =&gt; { # these settings override global settings<BR>&nbsp;&nbsp;&nbsp;&nbsp;auto_release_plans =&gt; 1<BR>&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;}<BR>&nbsp;],</DIV>
<DIV>&nbsp;gallery =&gt; [<BR>&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;_id =&gt; MongoDB::OID-&gt;new,<BR>&nbsp;&nbsp;&nbsp;project_name =&gt; '',<BR>&nbsp;&nbsp;&nbsp;location =&gt; '',<BR>&nbsp;&nbsp;&nbsp;comments =&gt; [ qw// ]<BR>&nbsp;&nbsp;},<BR>&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;_id =&gt; MongoDB::OID-&gt;new,<BR>&nbsp;&nbsp;&nbsp;project_name =&gt; '',<BR>&nbsp;&nbsp;&nbsp;location =&gt; ''<BR>&nbsp;&nbsp;}<BR>&nbsp;],</DIV>
<DIV>&nbsp;settings =&gt; { # Set per account_type<BR>&nbsp;&nbsp;auto_release_plans =&gt; 1,<BR>&nbsp;&nbsp;hide_general_email =&gt; 1<BR>&nbsp;}<BR>};</DIV>
<DIV>my $account_id = $account_col-&gt;insert( $account_data );</DIV>
<DIV>print Dumper( $account_col-&gt;find_one({ "_id" =&gt; $account_id }) );<BR></DIV>
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP