小编ara*_*een的帖子

Mongoose Schema尚未注册

我正在学习平均堆栈,当我尝试启动服务器时

npm start
Run Code Online (Sandbox Code Playgroud)

我得到一个例外说:

schema hasn't been registered for model 'Post'. Use mongoose.model(name, schema)
Run Code Online (Sandbox Code Playgroud)

这是我在/models/Posts.js中的代码

var mongoose = require('mongoose');

var PostSchema = new mongoose.Schema({
    title: String,
    link: String, 
    upvotes: { type: Number, default: 0 },
    comments: [{ type: mongoose.Schema.Types.ObjectId, ref: 'Comment' }]
});

mongoose.model('Post', PostSchema);
Run Code Online (Sandbox Code Playgroud)

正如我所看到的,应该为模型'Post'注册模式,但是什么可能导致异常被抛出?

提前致谢.

编辑:这是异常错误

/home/arash/Documents/projects/personal/flapper-news/node_modules/mongoose/lib/index.js:323
  throw new mongoose.Error.MissingSchemaError(name);
        ^
MissingSchemaError: Schema hasn't been registered for model "Post".
Use mongoose.model(name, schema)
Run Code Online (Sandbox Code Playgroud)

这是使用mongoose初始化的app.js代码:

var mongoose = require('mongoose');
mongoose.connect('mongodb://localhost/news');
require('./models/Posts');
require('./models/Comments');
Run Code Online (Sandbox Code Playgroud)

在行之前:

app.use('/', routes);
Run Code Online (Sandbox Code Playgroud)

mongoose mongodb node.js

59
推荐指数
8
解决办法
6万
查看次数

无法访问添加的服务引用

我已经为我的mvc4 web项目添加了一个服务引用,并将其保留为默认命名空间"ServiceReference1",但是当我想使用该命名空间时,visual studio无法找到它,就像它不存在一样,webservice已启动并且工作正常.我究竟做错了什么?

c# web-services service-reference asp.net-mvc-4

28
推荐指数
2
解决办法
4万
查看次数

毕加索没有加载图像

这是毕加索的代码:

ImageView img = (ImageView)findViewById(R.id.product_image);
    Picasso.with(this)
    .load(_url)
    .fit()
    .into(img, new Callback() {

        @Override
        public void onSuccess() {


        }

        @Override
        public void onError() {


        }
    });
Run Code Online (Sandbox Code Playgroud)

这是_url的价值:http: //kiagallery.ir/Images/Upload/Collection%20101/Spring%20101/d4a03b66dc7b46c694615c549b78b2e9.jpg

这是xml:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<ImageView 
    android:id="@+id/product_image"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />

<TextView 
    android:id="@+id/product_name"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textSize="13sp"
    android:layout_below="@id/product_image"/>

<TextView
    android:id="@+id/product_price"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textSize="13sp"
    android:layout_below="@id/product_name"/>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

你可以看到图像可以通过浏览器访问,但毕加索无法加载它,我已经检查了onError函数,它从未被调用,我很安静地丢失在这里,任何帮助将不胜感激.

编辑:当我给imageview的宽度和高度固定值像200dp时,它加载图像,但当我将其更改为wrap_content时,它不显示图像.

android imageview picasso

14
推荐指数
2
解决办法
2万
查看次数

Facebook android shareDialog在开幕后关闭

之后我在我的Android应用程序中使用facebook sdk并进行测试我已将下面的代码添加到我的MainActivity中:

CallbackManager callbackManager;
ShareDialog shareDialog;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    FacebookSdk.sdkInitialize(getApplicationContext());
    setContentView(R.layout.activity_main);

    callbackManager = CallbackManager.Factory.create();
    shareDialog = new ShareDialog(this);

    if (ShareDialog.canShow(ShareLinkContent.class)) {
        ShareLinkContent linkContent = new ShareLinkContent.Builder()
                .setContentTitle("Hello Facebook")
                .setContentDescription(
                        "The 'Hello Facebook' sample  showcases simple Facebook integration")
                .setContentUrl(Uri.parse("http://developers.facebook.com/android"))
                .build();

        shareDialog.show(linkContent);
    }
}
Run Code Online (Sandbox Code Playgroud)

我在清单中添加了以下步骤:

<uses-permission android:name="android.permission.INTERNET"/>

<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id"/>

<provider android:authorities="com.facebook.app.FacebookContentProvider950310748347640"
  android:name="com.facebook.FacebookContentProvider"
  android:exported="true" />

<activity android:name="com.facebook.FacebookActivity"
  android:configChanges=
             "keyboard|keyboardHidden|screenLayout|screenSize|orientation"
  android:theme="@android:style/Theme.Translucent.NoTitleBar"
  android:label="@string/app_name" />
Run Code Online (Sandbox Code Playgroud)

当我测试shareDialog弹出时突然它自动关闭.

java android facebook facebook-android-sdk

13
推荐指数
1
解决办法
5019
查看次数

IntelliJ Android运行时异常:ClassNotFound,未在路径上找到Class

使用IntelliJ 14.0.3,我的Android项目一直工作,直到我在彼此之后几次构建项目并且BANG,它不再出现并且它抛出了运行时异常:

java.lang.RuntimeException: Unable to instantiate activity 
 ComponentInfo{com.rahil.ecat/com.rahil.activity.Activity_Main}: 
 java.lang.ClassNotFoundException: Didn't find class 
 "com.rahil.activity.Activity_Main" on path: 
 DexPathList[[zip file "/data/app/com.rahil.ecat-1.apk"],
  nativeLibraryDirectories=[/data/app-lib/com.rahil.ecat-1, 
      /vendor/lib, /system/lib]]
Run Code Online (Sandbox Code Playgroud)

我搜索了SO并找到了一些不适用于IntelliJ的答案,它们都是针对Eclipse的,我很困惑如何解决这个问题,这让我发疯了.

有任何想法吗?

java android intellij-idea

10
推荐指数
1
解决办法
575
查看次数

带有预先填充的sqlite数据库的iOS发货申请表

我想用我预先填充的sqlite数据库发送我的ios应用程序(用swift编写),该数据库将通过与服务器同步来更新.在android我可以将数据库从assests文件夹移动到数据库和volla,但在ios中我很安静,我怎么能实现这一点?

谢谢

sqlite ios swift

7
推荐指数
1
解决办法
1576
查看次数

在多个值文件中具有多个列表的 Helm Charts

我有一个 values.yaml ,它具有以下内容:

abc:
  env:
  - name: name01
    value: value01
  - name: name02
    value: value02
Run Code Online (Sandbox Code Playgroud)

我还有另一个值文件 values-dev.yaml ,我在使用 -f 安装时添加了它,它有:

abc:
  env:
  - name: name03
    value: value03
Run Code Online (Sandbox Code Playgroud)

并使用范围将它们列在我的模板中。我希望在应用这两个文件后,列表会变成这样:

abc:
  env:
  - name: name01
    value: value01
  - name: name02
    value: value02
  - name: name03
    value: value03
Run Code Online (Sandbox Code Playgroud)

但是 values-dev.yaml 值将覆盖 values.yaml 中的值,它变成:

abc:
  env:
  - name: name03
    value: value03
Run Code Online (Sandbox Code Playgroud)

如何实现将这 2 个列表与来自不同值文件的相同字段名称合并?

kubernetes kubernetes-helm

6
推荐指数
1
解决办法
5431
查看次数

Android用边框画半圈

我想知道是否有可能绘制一个填充了一半的圆圈,如下所示:

在此输入图像描述

如果可能的话,稍后我想填充这个cirlce或者只剩下边框使它变空,这很好但是无论如何都要添加动画吗?比如从一个空圆圈到一半填充或完全填充的圆圈发生过渡?

提前致谢

android android-animation android-drawable

5
推荐指数
1
解决办法
6878
查看次数

在 C# 字符串中转义双引号

我试图逃脱\"在我的字符串中像这样:

text.Replace("\\", "\\\\").Replace("\"", "\\\"");
Run Code Online (Sandbox Code Playgroud)

但结果为text

arash "moeen"
Run Code Online (Sandbox Code Playgroud)

结果是

text.Replace("\\", "\\\\").Replace("\"", "\\\"");
Run Code Online (Sandbox Code Playgroud)

我怎样才能解决这个问题?

c# string escaping double-quotes

5
推荐指数
1
解决办法
1万
查看次数

facebook android sdk sharedialog回调总是成功的

使用Facebook android sdk版本4.1.1,我设法打开shareDialog并使用以下代码共享内容:

if (ShareDialog.canShow(ShareLinkContent.class)) {
        ShareLinkContent linkContent = new ShareLinkContent.Builder()
                .setContentTitle("Hello Facebook")
                .setContentDescription(
                        "The 'Hello Facebook' sample  showcases simple Facebook integration")
                .setContentUrl(Uri.parse("http://developers.facebook.com/android"))
                .build();

        shareDialog.show(linkContent);
        shareDialog.registerCallback(callbackManager, new FacebookCallback<Sharer.Result>() {

            @Override
            public void onSuccess(Result result) {
                //always gets called

            }

            @Override
            public void onCancel() {
                //do something

            }

            @Override
            public void onError(FacebookException error) {
                // TODO Auto-generated method stub

            }

        });
    }
Run Code Online (Sandbox Code Playgroud)

以及ActivityResult代码的回调:

@Override
protected void onActivityResult(final int requestCode, final int resultCode, final Intent data) {
    super.onActivityResult(requestCode, resultCode, data); …
Run Code Online (Sandbox Code Playgroud)

java android facebook

5
推荐指数
1
解决办法
2432
查看次数