Chinaunix首页 | 论坛 | 博客
  • 博客访问: 5378962
  • 博文数量: 1144
  • 博客积分: 11974
  • 博客等级: 上将
  • 技术积分: 12312
  • 用 户 组: 普通用户
  • 注册时间: 2005-04-13 20:06
文章存档

2017年(2)

2016年(14)

2015年(10)

2014年(28)

2013年(23)

2012年(29)

2011年(53)

2010年(86)

2009年(83)

2008年(43)

2007年(153)

2006年(575)

2005年(45)

分类: Mysql/postgreSQL

2011-10-09 07:28:36

#!/usr/bin/perl
use warnings;
use strict;
use Data::Dumper;
use MongoDB;
use MongoDB::OID;
my $con = MongoDB::Connection->new;
my $db = $con->syncrobid;
my $account_col = $db->account;
$account_col->remove;
my $account_data = {
 # _id will be created automatically
 company_name => '',
 username => '',
 subscription_id => '', # used for Authorize.net
 fax => '',
 phone => '',
 address => {
  street => '',
  city => '',
  state => '',
  zip => ''
 },
 users => [
  {
   _id => MongoDB::OID->new,
   f_name => '',
   l_name => '',
   phone => '',
   ext => '',
   mobile => '',
   email => '',
   tasks => [ '', '', '' ],
   settings => {
    admin => 1,
    block_email => 1
   }
  }
 ],
 projects => [
  {
   _id => MongoDB::OID->new,
   name => '',
   area => '',
   union_status => '',
   users => [], # Like a has_many relationship, retrieve to get a list of users ids that are working on this current project
   task => [ qw// ],
 
   revision => [
    {
     _id => MongoDB::OID->new,
     name => '',
     due_date => DateTime->now,
     created_timestamp => DateTime->now,
     files => [ qw// ]
    },
    {
     _id => MongoDB::OID->new,
     name => '',
     due_date => DateTime->now,
     created_timestamp => DateTime->now,
     files => [ qw// ]
    }
   ],
   settings => { # these settings override global settings
    auto_release_plans => 1
   }
  }
 ],
 gallery => [
  {
   _id => MongoDB::OID->new,
   project_name => '',
   location => '',
   comments => [ qw// ]
  },
  {
   _id => MongoDB::OID->new,
   project_name => '',
   location => ''
  }
 ],
 settings => { # Set per account_type
  auto_release_plans => 1,
  hide_general_email => 1
 }
};
my $account_id = $account_col->insert( $account_data );
print Dumper( $account_col->find_one({ "_id" => $account_id }) );
阅读(1608) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~