我尝试做一个选择在MongoDB与Mongoose像这样的东西:
SQL
SELECT * FROM PRODUCTS WHERE NAME LIKE '%Sorv%';
所以,我有一个Product模型:
mongoose.model('Products'
, new mongoose.Schema({
name: {type: String, default: ''},
price: {type: Number, default: 0},
prices: [Number]
})
, 'products');
Run Code Online (Sandbox Code Playgroud)
如果我尝试在Product模型中获取所有寄存器,它将返回正确的:
Product.find()
.then(function (result)
{
var names = result.map(function (item)
{
return item.name;
});
// return ["Sorvete", "Sorvete Morango", "Sorvete Morango", "Sorvete", "Sorvete"]
console.log(names);
});
Run Code Online (Sandbox Code Playgroud)
为什么当我Regex根据Mongoose文档进行查找时,它返回一个空数组?
Product.find({name: /Sorv/})
.then(function (result)
{
// return a empty array: []
console.log(result); …Run Code Online (Sandbox Code Playgroud) 如何Node Webkit在应用程序启动时自动配置打开的开发工具?
我可以通过package.jsonconfigure 或 来做到这一点javascript吗?
我有以下数据库结构:
用户
邮政
所以我在模型中创建关系函数:
class User extends Model {
public function post()
{
return $this->hasMany(Post::class);
}
}
Run Code Online (Sandbox Code Playgroud)
如果我执行$user->post将返回完整的帖子对象。
如何才能只获取帖子ID?
我尝试在我的页面中获取所有控件Page.Controls,但它只返回他的Master Page控件,如何才能获得此内容页面控件?
<%@ Page Title="" Language="C#" MasterPageFile="~/Template/ManagerTemplate.Master" AutoEventWireup="true" CodeBehind="Cliente.aspx.cs" Inherits="SistemaPedido.Cadastro.Cliente" %>
Run Code Online (Sandbox Code Playgroud)
我的活动
protected void Page_Load(object sender, EventArgs e)
{
Page.LoadComplete += (s, arg) =>
{
foreach (Control Control in Page.Controls)
{
Response.Write(Control.ClientID + "<br/>");
}
};
}
Run Code Online (Sandbox Code Playgroud) 我知道可以使用元素获取范围:
yourScope = angular.element($(".yourTag")).scope();
Run Code Online (Sandbox Code Playgroud)
但是如果我需要在同一个控制器中注入依赖项,例如:
someModule.controller('MyController', ['$scope', 'greeter', function($scope, greeter) {
// ...
}]);
Run Code Online (Sandbox Code Playgroud)
我怎样才能得到greeter依赖$scope?这个有可能?
当execute new Date()会返回一个字符串看起来像Tue Aug 11 2015 14:42:04 GMT-0300 (Hora oficial do Brasil)
当我使用typeof new Date()它时会返回一个object,直到这一点为止
但为什么我不能在Chrome控制台中显示您的属性和功能,但我可以访问他们的?
当我执行:
var date = new Date();
console.log(date);
Run Code Online (Sandbox Code Playgroud)
它会回来Tue Aug 11 2015 14:42:04 GMT-0300 (Hora oficial do Brasil),为什么不Date {....}呢?
@taxicala
我尝试创建fallowing类:
function teste() {
return 'Hello World';
}
var t = new teste();
typeof t; // "object"
console.log(t); // return 'teste{}'
Run Code Online (Sandbox Code Playgroud)
如何创建类(函数)之类的Date()?
javascript ×4
angularjs ×1
asp.net ×1
c# ×1
console.log ×1
eloquent ×1
events ×1
laravel ×1
master-pages ×1
mongodb ×1
mongoose ×1
node-webkit ×1
node.js ×1
php ×1