當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript cubitt-graph-cqrs.CQRSGraph類代碼示例

本文整理匯總了TypeScript中cubitt-graph-cqrs.CQRSGraph的典型用法代碼示例。如果您正苦於以下問題:TypeScript CQRSGraph類的具體用法?TypeScript CQRSGraph怎麽用?TypeScript CQRSGraph使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了CQRSGraph類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1:

						connection.commit(function(res, res_err) {
							if (res_err) {
								// Should be automatically rollbacked
								console.log("Failed to commit data " + res_err);
								graph.Rollback();
								return;
							}
							graph.CommitTransaction();
							message.reply(JSON.stringify({ status: 200, data: { version: graph.GetVersion() }, error: null }));
							for (let ev in events) {
								eb.publish("projects.events." + projectId, JSON.stringify(ev));
							}
							return;
						});
開發者ID:uu-cubitt,項目名稱:command-handler,代碼行數:14,代碼來源:cubitt-command-manager.ts

示例2: function

				var applyCommand = function(index) {
					if (index == 0) {
						graph.BeginTransaction();
					}
					if (index === commands.length) {
						connection.commit(function(res, res_err) {
							if (res_err) {
								// Should be automatically rollbacked
								console.log("Failed to commit data " + res_err);
								graph.Rollback();
								return;
							}
							graph.CommitTransaction();
							message.reply(JSON.stringify({ status: 200, data: { version: graph.GetVersion() }, error: null }));
							for (let ev in events) {
								eb.publish("projects.events." + projectId, JSON.stringify(ev));
							}
							return;
						});
					} else {
						try
						{
							let comm = commands[index];
							let event = graph.ApplyCommand(comm);
							connection.updateWithParams(
								"INSERT INTO \"" + projectId + "_events\" VALUES(?,cast(? as json))",
								[graph.GetVersion(), event.toJson()],
								function (res, res_err) {
									if (res_err) {
										console.log("Inserting event failed " + res_err);
										rollback(new Error("Internal server error"), index);
										return;
									}
									events.push(event);
									applyCommand(index+1);
							});
						// This catch block is for the graph.ApplyCommand, not for the DB query
						// see (https://www.joyent.com/developers/node/design/errors#fn:1)
						} catch (error) {
							rollback(error, index);
							return;
						}
					}
				}
開發者ID:uu-cubitt,項目名稱:command-handler,代碼行數:44,代碼來源:cubitt-command-manager.ts

示例3: function

			connection.query("SELECT event FROM \"" + projectId + "_events\" WHERE id <= " + version, function(res, res_err) {
				if (res_err) {
					console.log("Could not load events from eventstore " + res_err);
					vertx.close();
					return;
				}
				let results = res.results;
				Array.prototype.forEach.call(results, function(row) {
					let event = row[0];
					graph.ApplyEvent(JSON.parse(event));
				});
				message.reply(JSON.stringify(graph.GetGraph().serialize()));
			});
開發者ID:uu-cubitt,項目名稱:query-builder,代碼行數:13,代碼來源:cubitt-query-builder.ts


注:本文中的cubitt-graph-cqrs.CQRSGraph類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。