首页 \ 问答 \ 哪个MEAN生成器 - javascript(Which MEAN Generator - javascript)

哪个MEAN生成器 - javascript(Which MEAN Generator - javascript)

我只是这个领域的新手,我的意思是使用javascript开发网络应用程序。

我正在学习如何在后端使用NodeJS + express,但与此同时我试图继续在前端使用AngularJS。 我还为应用程序的脚手架安装了yeoman; 实际上我正在使用generator-angularexpress。

所以,我的问题是:你认为哪个生成器是Web应用程序脚手架的最佳生成器,请记住我想构建一个MEAN堆栈?

谢谢大家!


I'm just a newbie in this field, I mean at the development of web apps using javascript.

I was learning how to use NodeJS + express on the backend, but at the same time I was trying to go ahead with the use of AngularJS on the front-end. I also installed yeoman for the scaffolding of the app; actually I was using generator-angularexpress.

So, my question is: which generator do you consider to be the best one for the scaffolding of the web app, keeping in mind that I want to build a MEAN stack?

Thank you folks!


原文:https://stackoverflow.com/questions/19287035
更新时间:2021-12-15 08:12

最满意答案

我相信最耗时的部分应该是执行查询。 如果你使用whereIn ,那么我认为你只能执行一次查询,然后遍历结果。 我没有测试过,但它应该是这样的:

$purchasesByYear = \App\Inventory::select('purchase_year',
    DB::raw('count(*) as purchase_count'))
        ->whereIn('purchase_year', $purchaseYears)
        ->groupBy('purchase_year')->get();

我认为减少查询执行次数将是阻止其慢慢运行的主要机会。 此外,我认为如果您还没有这样做,那么在purchase_year中添加索引应该会有所帮助。

你可以使用一些数学来代替很多其他条件来处理这些年份的分组。 这实际上可能稍慢,但代码重复性稍差,我相信你对这部分所做的任何事情都将是微观优化,而不是你可以对查询部分做什么。 我的建议:

foreach ($purchasesByYear as $purchaseYear) {
    $year = $purchaseYear->purchase_year;
    if ($year < 1960) {
        $yearRange = 'Pre 1960';
    } else {
        // subtract one until the year is a multiple of five
        while ($year % 5) { $year--; }
        // then construct the range string using the starting number
        $yearRange = $year.'-'.($year+4);
    }
    if (isset($chartData[$yearRange])) {
        $chartData[$yearRange] += $purchaseYear->purchase_count;
    } else {
        $chartData[$yearRange] = $purchaseYear->purchase_count;
    }
}

I believe the most time consuming part should be executing the query. If you use whereIn, then I think you can execute the query only once, and then loop over the results. I haven't tested it, but it should be something like this:

$purchasesByYear = \App\Inventory::select('purchase_year',
    DB::raw('count(*) as purchase_count'))
        ->whereIn('purchase_year', $purchaseYears)
        ->groupBy('purchase_year')->get();

I think reducing the number of query executions will be the main opportunity to keep this from running slowly. Also, I think adding an index to purchase_year should be helpful if you have not already done so.

Instead of a lot of elseif conditions to handle grouping the years, you could use some math. This might actually be slightly slower, but the code would be a little less repetitive, and I believe anything you do to this part will be a micro-optimization compared to what you can do with the query part. My suggestion:

foreach ($purchasesByYear as $purchaseYear) {
    $year = $purchaseYear->purchase_year;
    if ($year < 1960) {
        $yearRange = 'Pre 1960';
    } else {
        // subtract one until the year is a multiple of five
        while ($year % 5) { $year--; }
        // then construct the range string using the starting number
        $yearRange = $year.'-'.($year+4);
    }
    if (isset($chartData[$yearRange])) {
        $chartData[$yearRange] += $purchaseYear->purchase_count;
    } else {
        $chartData[$yearRange] = $purchaseYear->purchase_count;
    }
}

相关问答

更多
  • 使用提示能够独立计划看起来像光标计划,并修复了速度问题。 修复查询:(并非一直修复为OPTION失败) select max(list.match) as 'max' from ( SELECT count(*) as 'match' FROM [docSVenum1] with (nolock) INNER LOOP JOIN [FTSindexWordOnce] as w1 with (NOLOCK, FORCESEEK) ...
  • 不比其他方法更好,但你也可以在每个方向上使用np.roll来做同样的事情: def evolve_heat_slow(u): u2 = u.copy() u2[1:-1, 1:-1] = ((np.roll(u2,1,0) + np.roll(u2,-1,0) + np.roll(u2,1,1) + np.roll(u2,-1,1))/4)[1:-1, 1:-1] return u2 现在用u2 = evolve_heat_slow ...
  • 这绝不是优雅的,但似乎有效: library(jsonlite) library(purrr) library(dplyr) json_data <- '[{"data":{"id":"3f066cdd81cf4944b42230ed56a35bce","awards":[{"status":"unsuccessful","value":{"amount":76}},{"status":"active","value":{"amount":41220}}],"value":{"amount":48000} ...
  • 基准 这个自制的随机基准测试表明,在大多数情况下,使用in的解决方案明显更快。 我没有调查,但我确实遇到了一些运行,其中嵌套for循环的解决方案在使用样本大小时稍快。 import time, random def time_it(f, rep=100000): sample = [[random.randint(0, 100) for _ in range(20)] for _ in range(rep // 100)] start = time.time() for i in ...
  • 通过使用同步和异步,速度不会受到任何影响。 互联网的速度是一样的。 问题是你绝不能在主线程上进行同步网络调用。 这样做会锁定用户界面。 最好的情况是你的应用出现锁定到用户(坏)。 更糟糕的是,操作系统杀死你的应用程序无响应(坏)。 所有的联网应该在后台完成。 如果你的应用程序在所有的网络访问完成之后才能真正进行,至少你可以建立一个“忙碌”的屏幕,让用户知道发生了什么。 也许使用进度条让用户知道进程有多远,或者显示文件数量的“x of y”计数。 什么是适合你的应用程序。 但同样,网络访问的速度不会改变。 您 ...
  • 如果你考虑一下,那么.hasOwnProperty()方法会更快,因为它只使用1 for loop 。 错误 我其实有点惊讶。 我期待双循环更慢。 但我想你无法估计for loop的速度。 双循环 虽然这对我来说似乎是最慢的,但这实际上最终成为7,291,083 ops/sec的最快7,291,083 ops/sec .hasOwnProperty() 我可以看到这会慢,因为函数比语句慢。 这个1,730,588 ops/sec为1,730,588 ops/sec if..in @Geuis回答包括if.. ...
  • 这有点宽泛,但是当处理器数量大于1并且slowMethod是独立的时,使用具有固定线程号的ExecutorService会使其更快。 如果slowMethod是I / O密集型,则可以增加线程数以获得更高的性能。 import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; public class Main { public static void main(String[] args) ...
  • 我相信最耗时的部分应该是执行查询。 如果你使用whereIn ,那么我认为你只能执行一次查询,然后遍历结果。 我没有测试过,但它应该是这样的: $purchasesByYear = \App\Inventory::select('purchase_year', DB::raw('count(*) as purchase_count')) ->whereIn('purchase_year', $purchaseYears) ->groupBy('purchase_yea ...
  • 这是一个缓冲问题。 .at提供无缓冲的操作http://docs.scipy.org/doc/numpy/reference/generated/numpy.ufunc.at.html#numpy.ufunc.at np.add.at(grid_array, (xidx,yidx,zidx),data) This is a buffering issue. The .at provides unbuffered action http://docs.scipy.org/doc/numpy/referenc ...
  • 这应该快得多: bigPattern <- paste('(\\b',city[,1],'\\b)',collapse='|',sep='') txt$city <- sapply(regmatches(txt$txt,gregexpr(bigPattern,txt$txt)),FUN=function(x) ifelse(length(x) == 0,'NONE',paste(unique(x),collapse='_'))) 说明: 在第一行中,我们构建了一个匹配所有城市的大型正则表达式,例如: (\ ...

相关文章

更多

最新问答

更多
  • h2元素推动其他h2和div。(h2 element pushing other h2 and div down. two divs, two headers, and they're wrapped within a parent div)
  • 创建一个功能(Create a function)
  • 我投了份简历,是电脑编程方面的学徒,面试时说要培训三个月,前面
  • PDO语句不显示获取的结果(PDOstatement not displaying fetched results)
  • Qt冻结循环的原因?(Qt freezing cause of the loop?)
  • TableView重复youtube-api结果(TableView Repeating youtube-api result)
  • 如何使用自由职业者帐户登录我的php网站?(How can I login into my php website using freelancer account? [closed])
  • SQL Server 2014版本支持的最大数据库数(Maximum number of databases supported by SQL Server 2014 editions)
  • 我如何获得DynamicJasper 3.1.2(或更高版本)的Maven仓库?(How do I get the maven repository for DynamicJasper 3.1.2 (or higher)?)
  • 以编程方式创建UITableView(Creating a UITableView Programmatically)
  • 如何打破按钮上的生命周期循环(How to break do-while loop on button)
  • C#使用EF访问MVC上的部分类的自定义属性(C# access custom attributes of a partial class on MVC with EF)
  • 如何获得facebook app的publish_stream权限?(How to get publish_stream permissions for facebook app?)
  • 如何防止调用冗余函数的postgres视图(how to prevent postgres views calling redundant functions)
  • Sql Server在欧洲获取当前日期时间(Sql Server get current date time in Europe)
  • 设置kotlin扩展名(Setting a kotlin extension)
  • 如何并排放置两个元件?(How to position two elements side by side?)
  • 如何在vim中启用python3?(How to enable python3 in vim?)
  • 在MySQL和/或多列中使用多个表用于Rails应用程序(Using multiple tables in MySQL and/or multiple columns for a Rails application)
  • 如何隐藏谷歌地图上的登录按钮?(How to hide the Sign in button from Google maps?)
  • Mysql左连接旋转90°表(Mysql Left join rotate 90° table)
  • dedecms如何安装?
  • 在哪儿学计算机最好?
  • 学php哪个的书 最好,本人菜鸟
  • 触摸时不要突出显示表格视图行(Do not highlight table view row when touched)
  • 如何覆盖错误堆栈getter(How to override Error stack getter)
  • 带有ImageMagick和许多图像的GIF动画(GIF animation with ImageMagick and many images)
  • USSD INTERFACE - > java web应用程序通信(USSD INTERFACE -> java web app communication)
  • 电脑高中毕业学习去哪里培训
  • 正则表达式验证SMTP响应(Regex to validate SMTP Responses)