#!/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 }) );
阅读(1602) | 评论(0) | 转发(0) |