da2e92003f
Tweets added to server New svelte front end
108 lines
4.7 KiB
JavaScript
108 lines
4.7 KiB
JavaScript
print('------------------- Initialising Database Collections and Indexes --------------------------------');
|
|
|
|
/**
|
|
* Mongo shell defaults to the 'test' database unless told otherwise. So explictly choose the MDB database.
|
|
*/
|
|
db = db.getSiblingDB('TWITTER');
|
|
print('Creating collections in:');
|
|
printjson(db);
|
|
print('Existing collections:');
|
|
printjson(db.getCollectionNames());
|
|
|
|
print('Adding collections. This may take some time...');
|
|
|
|
db.createCollection('Tweets');
|
|
db.Account.dropIndexes();
|
|
db.Account.createIndex({ 'TweetID':1 }, { 'unique':true, 'sparse':true, 'name':'getTweetByID' });
|
|
|
|
/*
|
|
|
|
db.createCollection('AccountArchive');
|
|
db.AccountArchive.dropIndexes();
|
|
db.AccountArchive.createIndex({'ClientID':1},{'unique':false,'sparse':true,'name':'getAccountByClientID'});
|
|
|
|
db.createCollection('Address');
|
|
db.Address.dropIndexes();
|
|
db.Address.createIndex({'ClientID':1},{'unique':false,'sparse':true,'name':'getAddressesForClientID'});
|
|
db.Address.createIndex({'_id':1,'ClientID':1},{'unique':true,'sparse':true,'name':'getAddressForClientID'});
|
|
|
|
db.createCollection('AddressArchive');
|
|
db.AddressArchive.dropIndexes();
|
|
db.AddressArchive.createIndex({'ClientID':1},{'unique':false,'sparse':true,'name':'getAddressArchiveForClientID'});
|
|
|
|
db.createCollection('BridgeLogin');
|
|
db.BridgeLogin.dropIndexes();
|
|
|
|
db.createCollection('Client');
|
|
db.Client.dropIndexes();
|
|
db.Client.createIndex({'ClientID':1},{'unique':true,'sparse':true,'name':'getClientByClientID'});
|
|
db.Client.createIndex({'ClientName':1},{'unique':true,'sparse':true,'name':'getClientByClientName'});
|
|
|
|
db.createCollection('ClientArchive');
|
|
db.ClientArchive.dropIndexes();
|
|
db.ClientArchive.createIndex({'ClientID':1},{'unique':false,'sparse':true,'name':'getClientByClientID'});
|
|
|
|
db.createCollection('Device');
|
|
db.Device.dropIndexes();
|
|
db.Device.createIndex({'DeviceToken':1},{'unique':true,'name':'getDevicesByToken'});
|
|
db.Device.createIndex({'DeviceNumber':1},{'unique':true,'sparse':true,'name':'getDevicesByNumber'});
|
|
db.Device.createIndex({'ClientID':1},{'unique':false,'name':'getDevicesByClientID'});
|
|
|
|
db.createCollection('DeviceArchive');
|
|
db.DeviceArchive.dropIndexes();
|
|
db.DeviceArchive.createIndex({'ClientID':1},{'unique':false,'name':'getDevicesByClientID'});
|
|
|
|
db.createCollection('Images');
|
|
db.Images.dropIndexes();
|
|
db.Images.createIndex({'ClientID':1},{'unique':false,'sparse':true,'name':'getImagesByClientID'});
|
|
|
|
db.createCollection('Items');
|
|
db.Items.dropIndexes();
|
|
db.Items.createIndex({'ClientID':1},{'unique':false,'sparse':true,'name':'getItemsByClientID'});
|
|
|
|
db.createCollection('Messages');
|
|
db.Messages.dropIndexes();
|
|
db.Messages.createIndex({'ClientID':1,'TimeFilter':1},{'unique':false,'sparse':true,'name':'getMessagesByClientIDandTime'});
|
|
|
|
db.createCollection('MessagesArchive');
|
|
db.MessagesArchive.dropIndexes();
|
|
db.MessagesArchive.createIndex({'ClientID':1},{'unique':false,'sparse':true,'name':'getMessagesByClientID'});
|
|
|
|
db.createCollection('PayCode');
|
|
db.PayCode.dropIndexes();
|
|
db.PayCode.createIndex({'PayCode':1},{'unique':true,'sparse':true,'name':'getCurrentPayCodes'});
|
|
db.PayCode.createIndex({'Expiry':1},{expireAfterSeconds:0,'name':'payCodeTTL'});
|
|
|
|
db.createCollection('SystemLog');
|
|
db.SystemLog.dropIndexes();
|
|
db.SystemLog.createIndex({'DateTime':-1},{'unique':false,'sparse':true,'name':'getEntryByTime'});
|
|
|
|
db.createCollection('Transaction');
|
|
db.Transaction.dropIndexes();
|
|
db.Transaction.createIndex({'MerchantInvoiceNumber.InvoiceNumber':-1,'MerchantInvoiceNumber.MerchantID':-1,'MerchantInvoiceNumber.MerchantIndex':1},{'unique':true,partialFilterExpression:{MerchantInvoiceNumber:{$exists:true}},name:'MerchantInvoiceNumberIndex'});
|
|
|
|
db.createCollection('TransactionArchive');
|
|
db.TransactionArchive.dropIndexes();
|
|
db.TransactionArchive.createIndex({'CustomerClientID':1},{'unique':false,'sparse':true,'name':'getTransactionsByClientID'});
|
|
|
|
db.createCollection('TransactionHistory');
|
|
db.TransactionHistory.dropIndexes();
|
|
db.TransactionHistory.createIndex({'ClientID':1,'AccountID':1,'SaleTime':1},{'unique':false,'sparse':true,'name':'getHistoryByClient'});
|
|
db.TransactionHistory.createIndex({'AccountID':1},{'unique':false,'sparse':true,'name':'getHistoryByAccount'});
|
|
db.TransactionHistory.createIndex({'OtherImage':1},{'unique':false,'sparse':true,'name':'findImage'});
|
|
|
|
db.createCollection('TwoFARequests');
|
|
db.TwoFARequests.dropIndexes();
|
|
db.TwoFARequests.createIndex({'RequestExpiry':1},{'unique':false,expireAfterSeconds:0,'name':'requestTTL'});
|
|
|
|
db.createCollection('WebConsoleSessions');
|
|
db.WebConsoleSessions.dropIndexes();
|
|
db.WebConsoleSessions.createIndex({'expires': 1}, {expireAfterSeconds: 60, 'name': 'webConsoleSessionsTTL'});
|
|
*/
|
|
|
|
print('Collections added.');
|
|
print('Updated Collections:');
|
|
printjson(db.getCollectionNames());
|
|
|
|
print('------------------- DONE Initialising Database --------------------------------');
|