我有以下文件和代码
index.html
:
<!doctype html>
<html>
<head lang="en">
<title>Angular 2 Components</title>
</head>
<body>
<ngc-app></ngc-app>
<script src="https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.35.0/es6-shim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/2.0.0-beta.15/angular2-polyfills.js"></script>
<script src="jspm_packages/system.js"></script>
<script src="config.js"></script>
<script>
System.import('lib/bootstrap.js');
</script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
bootstrap.js
:
// Import Angular bootstrap function
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
// Import our main app component
import {App} from './app';
// We are bootstrapping Angular using our main application component
bootstrap(App);
Run Code Online (Sandbox Code Playgroud)
app.js
:
// We need the Component annotation as well as the
// ViewEncapsulation enumeration
import {Component, ViewEncapsulation} from '@angular/core';
// …
Run Code Online (Sandbox Code Playgroud) 我正在使用Laravel Excel,我想加载一个视图文件并将其设置为特定的行.用laravel excel可以做到吗?bellow是将视图加载到工作表中的代码:
Excel::create('New file', function($excel) {
$excel->sheet('New sheet', function($sheet) {
$sheet->loadView('folder.view');
});
});
Run Code Online (Sandbox Code Playgroud) 假设我有以下查询:
post.getSpecificDateRangeJobs = function(queryData, callback) {
var matchCriteria = queryData.matchCriteria;
var currentDate = new Date();
var match = { expireDate: { $gte: new Date(currentDate.getFullYear(), currentDate.getMonth(), currentDate.getDate()) } };
if (queryData.matchCriteria !== "") {
match = {
expireDate: { $gte: new Date(currentDate.getFullYear(), currentDate.getMonth(), currentDate.getDate()) },
$text: { $search: matchCriteria }
};
}
var pipeline = [
{
$match: match
},
{
$group: {
_id: null,
thirtyHourAgo: {
$sum: {
$cond: [
{
$gte: [
"$publishDate",
new Date(queryData.dateGroups.thirtyHourAgo)
]
},
1,
0 …
Run Code Online (Sandbox Code Playgroud) 我有以下模型:1-用户模型
/**
* Define user and functional area relationship
*/
public function functionalAreas()
{
return $this->belongsToMany('App\FunctionalArea', 'user_functional_areas', 'user_id', 'functional_area_id')->withPivot('id', 'is_primary')->withTimestamps();
}
Run Code Online (Sandbox Code Playgroud)
和商业模式:
/**
* Define business and user functional area relationship
*/
public function functionalAreas()
{
return $this->belongsToMany('App\FunctionalArea', 'business_functional_areas', 'business_id', 'functional_area_id')->withTimestamps();
}
Run Code Online (Sandbox Code Playgroud)
现在我应该将所有企业和用户显示在一个列表中,为此我使用来自 union,以下是我的查询:
public function usersAndOrganizations()
{
$users = $this->users();
$organizations = $this->organizations();
$invitees = $users->union($organizations)->paginate(10);
return response()->json($invitees);
}
private function users()
{
$users = User::byState($approved = true, 'is_approved')
->search()->select([
'id',
DB::raw("CONCAT(first_name, ' ', last_name) AS name"),
'about',
'address', …
Run Code Online (Sandbox Code Playgroud) 我有以下查询:
db.getCollection('user').aggregate([
{$unwind: "$education"},
{$project: {
duration: {"$divide":[{$subtract: ['$education.to', '$education.from'] }, 1000 * 60 * 60 * 24 * 365]}
}},
{$group: {
_id: '$_id',
"duration": {$sum: '$duration'}
}}]
])
Run Code Online (Sandbox Code Playgroud)
以上查询结果为:
{
"_id" : ObjectId("59fabb20d7905ef056f55ac1"),
"duration" : 2.34794520547945
}
/* 2 */
{
"_id" : ObjectId("59fab630203f02f035301fc3"),
"duration" : 2.51232876712329
}
Run Code Online (Sandbox Code Playgroud)
但我想要做的是以year
+ month
+ day
格式获取其持续时间,例如:2 y, 3 m, 20 d
.另外一点,如果一个球场上的to
球场是空的,另一个球场isGoingOn: true
,所以在这里我应该用当前日期而不是to
场来计算持续时间.用户有一系列课程子文档
education: [
{
"courseName": "Java",
"from" : ISODate("2010-12-08T00:00:00.000Z"),
"to" …
Run Code Online (Sandbox Code Playgroud) 之后我在app.js
文件服务器端有以下内容bodyParser
let dotEnv = require("dotenv");
dotEnv.load();
let express = require("express");
let app = express();
if (process.env.NODE_ENV === 'production') {
app = require('./public/web/server').app;
}
let passport = require("passport");
let server = require("http").Server(app);
let io = require("socket.io").listen(server);
// load intial configuration
require("./startup/initial-configuration")(app, io);
require("./server/config/socket")(io);
require("./server/config/database")(app, process.env.NODE_ENV);
require("./server/authentication/passport.local")(passport);
require("./server/authentication/passport.impersonate");
require("./startup/initial-routes")(app);
if (process.env.NODE_ENV === 'production') {
app.get('*.*', express.static('./public/web/browser', {
maxAge: '1y'
}));
app.get('*', (req, res) => {
res.render('index', {
req,
res
}, (err, html) => {
if (html) {
res.send(html);
} …
Run Code Online (Sandbox Code Playgroud) 我正在multer-s3-transform
将文件上传到s3,但是在上传之前我想调整文件大小,并保存为两个不同的大小。以下是我的代码,没有错误发生,但是文件未上传。
let multer = require("multer-s3-transform");
const aws = require('aws-sdk');
const sharp = require('sharp');
aws.config.update({
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
accessKeyId: process.env.AWS_ACCESS_KEY_ID
);
const s3 = new aws.S3();
var upload = multer({
storage: multerS3({
s3: s3,
bucket: process.env.AWS_BUCKET_NAME,
shouldTransform: function (req, file, cb) {
console.log("hereeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee");
let originalname = file.originalname;
file.stream.once('data', async function (firstChunk) {
let magic = firstChunk.toString('hex', 0, 4);
let extName = path.extname(originalname).toLowerCase();
// let filename = req.file.fieldname + '-' + Date.now() + path.extname(req.file.originalname);
if (checkMagicNumbers(magic, extName, req)) {
console.log("Valid File***************************"); …
Run Code Online (Sandbox Code Playgroud) 我想准备要插入的数据作为以下结构:
"_attachments": [
{
"container": "string",
"fileName": "string",
"name": "string",
"mime": "string",
"size": 0
}
]
Run Code Online (Sandbox Code Playgroud)
但我做了什么:
for(let key in _attachments) {
job._attachments[key]['container'] = _attachments[key]['container'];
job._attachments[key]['fileName'] = _attachments[key]['fileName'];
job._attachments[key]['name'] = _attachments[key]['name'];
job._attachments[key]['mime'] = _attachments[key]['mime'];
job._attachments[key]['size'] = _attachments[key]['size'];
}
Run Code Online (Sandbox Code Playgroud)
给出这个错误:
Unprocessable Entity
Run Code Online (Sandbox Code Playgroud)
注意:我正在使用环回.
假设我想将第2行的折叠和展开设置为最多4个作为一个组,将8个最多设置为12个第二个组.这意味着当用户想要单击+
组1的展开图标时,应该可以看到从2到4的行,对于组2,应该可以看到从8到12的行.贝娄是单排的代码.
$sheet->getRowDimension(1)->setOutlineLevel(1);
$sheet->getRowDimension(1)->setVisible(false);
$sheet->getRowDimension(1)->setCollapsed(true);
Run Code Online (Sandbox Code Playgroud)
我想在sort
子句中添加一个字段,仅用于一天前创建的那些文档。假设在我的集合中,mycollection
我的文档有一个字段publishDate
和其他一些字段,以下是我的查询:
db.getCollection('mycollection').aggregate([
{
"$match": {
"expireDate": {
"$gte": ISODate("2019-03-14T00:00:00.000Z")
},
"publishDate": {
"$lt": ISODate("2019-03-15T00:00:00.000Z")
},
"isPublished": true,
"isDrafted": false,
"deletedAt": {
"$eq": null
},
"deleted": false,
"blocked": {
"$exists": false
}
}
},
{
"$sort": {
"isFeatured": -1, // What I want is to add this field in sort clause by condition, when publishDate is yesterday, otherwise ignore it
"refreshes.refreshAt": -1,
"publishDate": -1,
"_id": -1
}
},
{
"$skip": 0
},
{
"$limit": 12 …
Run Code Online (Sandbox Code Playgroud) mongodb ×4
angular ×3
laravel ×3
mongoose ×3
node.js ×3
php ×3
mean-stack ×2
phpexcel ×2
typescript ×2
amazon-s3 ×1
eloquent ×1
express ×1
file-upload ×1
json ×1
laravel-5.1 ×1
laravel-6 ×1
multer-s3 ×1
mysql ×1
systemjs ×1