Merge pull request #17 from ryancrawcour/master

reorg of sample data
This commit is contained in:
Ryan CrawCour 2014-11-20 17:36:37 -08:00
Родитель 51bfa16720 94555ddd56
Коммит 1a54b4b832
5 изменённых файлов: 181 добавлений и 15 удалений

Просмотреть файл

@ -0,0 +1,155 @@
{
"Families": [
{
"id": "AndersenFamily",
"lastName": "Andersen",
"parents": [
{
"firstName": "Thomas"
},
{
"firstName": "Mary Kay"
}
],
"children": [
{
"firstName": "Henriette Thaulow",
"gender": "female",
"grade": 5,
"pets": [
{
"givenName": "Fluffy"
}
]
}
],
"address": {
"state": "WA",
"county": "King",
"city": "seattle"
},
"isRegistered": true
},
{
"id": "KinDocument",
"familyName": "Kin",
"parents": [
{
"givenName": "Tatsunari"
}
]
},
{
"id": "MeyerAndFamily",
"lastName": "Meyer",
"parents": [
{
"firstName": "April",
"pets": [
{
"givenName": "Wheeler"
}
]
}
],
"children": [
{
"firstName": "Chris",
"gender": "male"
}
]
},
{
"id": "TheAlexanders",
"familyName": "Alexander",
"parents": [
{
"givenName": "David"
}
],
"children": [
{
"givenName": "Michael",
"gender": "male",
"grade": 6
}
]
},
{
"id": "TheSmiths",
"familyName": "Smith",
"parents": [
{
"givenName": "Tony"
},
{
"givenName": "Denise",
"pets": [
{
"givenName": "Chewy"
}
]
}
],
"children": [
{
"givenName": "Jeff",
"gender": "male",
"grade": 2
},
{
"givenName": "Ben",
"gender": "male",
"grade": 5
},
{
"givenName": "Samantha",
"gender": "female",
"grade": 9
}
]
},
{
"id": "WakefieldFamily",
"parents": [
{
"familyName": "Wakefield",
"givenName": "Robin"
},
{
"familyName": "Miller",
"givenName": "Ben"
}
],
"children": [
{
"familyName": "Merriam",
"givenName": "Jesse",
"gender": "female",
"grade": 1,
"pets": [
{
"givenName": "Goofy"
},
{
"givenName": "Shadow"
}
]
},
{
"familyName": "Miller",
"givenName": "Lisa",
"gender": "female",
"grade": 8
}
],
"address": {
"state": "NY",
"county": "Manhattan",
"city": "NY"
},
"isRegistered": false
}
]
}

Просмотреть файл

@ -35,8 +35,12 @@
</PropertyGroup>
<ItemGroup>
<Compile Include="app.js" />
<Content Include="Data\Families.json" />
<Content Include="package.json" />
<Content Include="README.md" />
</ItemGroup>
<ItemGroup>
<Folder Include="Data\" />
</ItemGroup>
<Import Project="$(VSToolsPath)\Node.js Tools\Microsoft.NodejsTools.targets" />
</Project>

Просмотреть файл

@ -19,15 +19,21 @@ console.log();
var DocumentDBClient = require('documentdb').DocumentClient;
var config = require('../config');
var fs = require('fs');
var databaseId = config.names.database;
var collectionId = config.names.collection;
var documentDefinitions = function () {
var data = fs.readFileSync('./Data/Families.json');
return JSON.parse(data).Families;
};
// Establish a new instance of the DocumentDBClient to be used throughout this demo
var client = new DocumentDBClient(config.connection.endpoint, { masterKey: config.connection.authKey });
// Get some sample data
documentDefinitions = config.documentDefinitions();
// Load our sample data
sampleDocuments = documentDefinitions();
//-----------------------------------------------------------------------------------------
// This demo performs a few steps
@ -125,8 +131,8 @@ function getDocumentById(collectionLink, id, callback) {
function insertDocuments(collectionLink, callback) {
var createdList = [];
var counter = 0;
for (var i = 0; i < documentDefinitions.length; i++){
var docDef = documentDefinitions[i];
for (var i = 0; i < sampleDocuments.length; i++){
var docDef = sampleDocuments[i];
client.createDocument(collectionLink, docDef, function (err, created) {
if (err) {
@ -137,7 +143,7 @@ function insertDocuments(collectionLink, callback) {
createdList.push(created);
console.log('Document with id \'' + created.id + '\' created.');
if (counter === documentDefinitions.length - 1) {
if (counter === sampleDocuments.length - 1) {
callback(createdList);
}
});

Просмотреть файл

@ -8,16 +8,17 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{73AD5D45-8723-49D0-BBD0-733375826AA1}"
ProjectSection(SolutionItems) = preProject
config.js = config.js
Data.json = Data.json
EndProjectSection
EndProject
Project("{9092AA53-FB77-4645-B42D-1CCCA6BD08BD}") = "DocumentDB.Samples.CollectionManagement", "DocumentDB.Samples.CollectionManagement\DocumentDB.Samples.CollectionManagement.njsproj", "{6FEAE190-7F5C-4A1C-BB11-843B66A7E772}"
EndProject
Project("{9092AA53-FB77-4645-B42D-1CCCA6BD08BD}") = "DocumentDB.Samples.DocumentManagement", "DocumentDB.Samples.DocumentManagement\DocumentDB.Samples.DocumentManagement.njsproj", "{B136DF45-8A6B-4F3B-92F1-F4F9C40B0FC1}"
EndProject
Project("{9092AA53-FB77-4645-B42D-1CCCA6BD08BD}") = "DocumentDB.Samples.ServerSideScripts", "DocumentDB.Samples.ServerSideScripts\DocumentDB.Samples.ServerSideScripts.njsproj", "{CC9E34AB-7D33-46D0-B366-CC07F870E0AA}"
EndProject
Global
GlobalSection(TeamFoundationVersionControl) = preSolution
SccNumberOfProjects = 4
SccNumberOfProjects = 5
SccEnterpriseProvider = {4CA58AB2-18FA-4F8D-95D4-32DDF27D184C}
SccTeamFoundationServer = http://sqlbuvsts01:8080/main
SccLocalPath0 = .
@ -30,6 +31,9 @@ Global
SccProjectUniqueName3 = DocumentDB.Samples.DocumentManagement\\DocumentDB.Samples.DocumentManagement.njsproj
SccProjectName3 = DocumentDB.Samples.DocumentManagement
SccLocalPath3 = DocumentDB.Samples.DocumentManagement
SccProjectUniqueName4 = DocumentDB.Samples.ServerSideScripts\\DocumentDB.Samples.ServerSideScripts.njsproj
SccProjectName4 = DocumentDB.Samples.ServerSideScripts
SccLocalPath4 = DocumentDB.Samples.ServerSideScripts
EndGlobalSection
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -48,6 +52,10 @@ Global
{B136DF45-8A6B-4F3B-92F1-F4F9C40B0FC1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B136DF45-8A6B-4F3B-92F1-F4F9C40B0FC1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B136DF45-8A6B-4F3B-92F1-F4F9C40B0FC1}.Release|Any CPU.Build.0 = Release|Any CPU
{CC9E34AB-7D33-46D0-B366-CC07F870E0AA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CC9E34AB-7D33-46D0-B366-CC07F870E0AA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CC9E34AB-7D33-46D0-B366-CC07F870E0AA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CC9E34AB-7D33-46D0-B366-CC07F870E0AA}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

Просмотреть файл

@ -1,6 +1,4 @@
var fs = require('fs');
exports.connection = {
exports.connection = {
endpoint: 'https://ryancrawcour.documents.azure.com:443/',
authKey: 'NC4KZ6Lh5/wukMHMunWlFx6qWfjwMV1MIODmu4WfvL9smr1aT05wT2nD/w4+CKY49ljXHmNK6x8+ejMK3k64SQ=='
};
@ -8,9 +6,4 @@ exports.connection = {
exports.names = {
database: 'NodeSamples',
collection: 'Families',
};
exports.documentDefinitions = function () {
var data = fs.readFileSync('../Data.json');
return JSON.parse(data).Families;
};